Re: Garbage collector behavior



Your understanding is accurate. No idea if that's how the desktop framework
works - I've not researched it nearly as much as I have the CF.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com




"Vinz" <Vinz@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:27647BE8-4B0F-4FEE-B576-5752E0D1B71F@xxxxxxxxxxxxxxxx
Thanks a lot Chris,

From what I understand, if a finalizer is defined, when the object is not
used anymore (=null or out of scope) at the next collection the finaliser
is
added to the list of finaliser to execute, then when the finaliser is
done,
the next collection will free the object from the managed heap. So it
actually need more than one collection to free it from the managed heap.

If there is no finaliser the object is removed from the managed heap at
the
next collection.

What I'm not sure is when do the managed heap shrink? What I understand is
that EACH time the collection ends if there is more than 750k of free
memory
in the managed heap there is a compaction. Then after each compaction, if
there is more thant 1 MB of free memory in the heap, the virtal memory is
given back to the OS by blocks of 1 MB.

Of course you can correct me if I'm wrong. Is this also the behavior of
the
.NET framework or is it only for .NET CF?



"<ctacke/>" wrote:

The finalizer running has no direct relevence on the available system
memory. GC Collection is where any actual actiuon might (or might not)
occurr.

See this WebCast:

http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?culture=en-US&EventID=1032318791&CountryCode=US


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com


"Vinz" <Vinz@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:551899E7-E88B-45A5-8AC2-6EA31F173B73@xxxxxxxxxxxxxxxx
Hi,

I've seen a strange behavior with a C# application on Windows CE 5.0.
As
you
probably already know, in Windows CE 5.0 we only have 32 MB of memory.
I
create multiple instance of a really big object (1 MB of Data). My free
virtual memory for the process after all these allocations is 12 MB.
Then
the
destructor is called for each instance of the object. I supose that it
means
that the memory is freed. I should now have approximatly 30 MB of free
virtual memory for the process but I only have 12 MB.

What is the problem here? It seams that when managed code temporarly
needs
more memory, it never gives that memory back to the OS. Am I right? I
also
seen a lot of 64 kB commit in the memory map, does it means that when
the
managed heap is full it asks for a 64 kb block to the OS?

Where can I find more information on how the memory management is done
for
a
manged program under Windows CE 5.0?

Thanks a lot for your help,








.



Relevant Pages

  • Re: Growing Working Set Size on GUI App
    ... We use some tools to detect and fix memory leaks, ... the managed heap size was ... >> working set, ...
    (microsoft.public.dotnet.framework.performance)
  • Re: Growing Working Set Size on GUI App
    ... However, even if there are memory leaks, this doesn't explain the behaviour ... the managed heap size was 13MB. ... The Working Set increased in size by ~200MB. ...
    (microsoft.public.dotnet.framework.performance)
  • Re: Garbage collector behavior
    ... added to the list of finaliser to execute, then when the finaliser is done, ... actually need more than one collection to free it from the managed heap. ... that EACH time the collection ends if there is more than 750k of free memory ... in Windows CE 5.0 we only have 32 MB of memory. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: !sos.DumpHeap -stat -cache -gen 2 ==> high CPU and PageFaults
    ... Quote" "you have paged-out the debuggee's managed heap. ... I can find PC with 2GB of memory - but I'm not sure even this would be ... How much RAM do you have in your box? ...
    (microsoft.public.dotnet.framework.clr)
  • Re: Strange sudden shutdown issue with CF app
    ... Phone devices are notoriously low on virtual memory right out of the box because the OEMs decide to put every little thing into its own DLL and then have 25 processes launched at boot. ... Chris Tacke, Embedded MVP ... We have created an app that basically connects to a web service gets data, then stores it locally on the device, and when a record needs to be modified/added the system first tries to connect the web server sees if its availible, if not then it stores in locally on the device until the connection comes back, now I noticed that if the device does not mess around with the data connection then the application sits nicely as long as its open, and never gets shut down. ... But again most of the time I get no exception at all but just simply disappears. ...
    (microsoft.public.dotnet.framework.compactframework)