| Author |
Message |
mel1daa
Joined: 11 Jul 2012 Posts: 1
|
Posted: Wed Jul 11, 2012 5:02 pm Post subject: Multiple Snapshots needed to reduce memory in query bee |
|
|
Hi,
I am working with the query bee sample and after I close the form and remove the handler to the OnForegrounded event (in the Dispose() event of QueryForm), I take a snapshot. There is no memory drop. I take a second snapshot a few seconds later and the memory drops. I am noticing this with my own application as well - I need to take multiple snapshots to reduce the memory. I was under the impression that after a snapshot is taken, a GC.Collect() was invoked and the memory should drop. Am I doing something wrong?
David |
|
| Back to top |
|
 |
jessica.ramos
Joined: 23 Apr 2012 Posts: 76
|
Posted: Thu Jul 12, 2012 10:59 pm Post subject: |
|
|
Hi David!
As Andrew's described (http://www.red-gate.com/messageboard/viewtopic.php?t=9190), there are a few things that can cause .NET memory usage to appear not to change after a garbage collection:
* The # bytes in all heaps counter is often not accurate as it's only updated after a garbage collection, and there are times when .NET allocates more memory without causing a GC (and rare times when it releases memory outside of a GC). The private bytes counter is updated in real time.
* Fragmentation of the large object heap can prevent .NET from releasing memory back to the system. You can see free space in .NET heaps in the memory profiler, as well as the largest free contiguous block: if there is a lot of free space but the largest contiguous block is small then fragmentation is occurring.
* Objects referenced by objects with finalizers require at least 2 garbage collection cycles to be removed from memory, and possibly more if these references themselves have finalizers.
* .NET can maintain a pool of free memory for future object allocations if it thinks that there will be a lot of them (this allows it to postpone future garbage collections). It might decide to release this back to the system if there is another GC and not much of the free memory is used. This is often beneficial for the performance of server style applications. _________________ Jessica Ramos
Technical Support
Red Gate Software Ltd. |
|
| Back to top |
|
 |
|
|
All times are GMT + 1 Hour
|
| Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group