Memory Leaks

  • Thread starter Thread starter SLN
  • Start date Start date
S

SLN

Hi,

Im currently working on a C# appn and facing a problem
with memory leaks.

In our application we have a tabcontrol and tabpage
named "Main" in it. This tabpage has a treeview control
and upon clicking on any node we create a new tabpage and
add it to the tabcontrol.

Currently in our testing we have used the dotnet memory
profiler to take snapshots before creation of a new tab
page and after closing it. Ideally speaking, the delta
should be zero. When we compare the two snapshots we find
the following objects still remaining in memory.

Int32, WeakReference, BindingContext.HashKey and String.
The increase is consistent.

When i checked the call stack of the above instances, they
are getting created when a tabpage is added to the
tabcontrol.
tabCtrl.TabPages.Add(new TabPage());

we couldn't make out why they are getting created and why
not getting disposed.

Request any help on this issue.

Thanks in Advance,
Gupta.
 
Hi, [...]
tabCtrl.TabPages.Add(new TabPage());

we couldn't make out why they are getting created and why
not getting disposed.

Request any help on this issue.

Try calling GC.Collect() before taking the second memory sample. Normaly
the GC isn'T invoked immediately when you dispose an object. On Dispose
only unmanaged resources like filehandles get released. Memory is released
later when the GC is called.


--
------ooo---OOO---ooo------

Peter Koen - www.kema.at
MCAD CAI/RS CASE/RS IAT

------ooo---OOO---ooo------
 
Thank you Peter for responding.
I have the same problem even if i call GC.Collect().
-----Original Message-----
[email protected]:
Hi, [...]
tabCtrl.TabPages.Add(new TabPage());

we couldn't make out why they are getting created and why
not getting disposed.

Request any help on this issue.

Try calling GC.Collect() before taking the second memory sample. Normaly
the GC isn'T invoked immediately when you dispose an object. On Dispose
only unmanaged resources like filehandles get released. Memory is released
later when the GC is called.


--
------ooo---OOO---ooo------

Peter Koen - www.kema.at
MCAD CAI/RS CASE/RS IAT

------ooo---OOO---ooo------
.
 
This is because the .Net Memory Profiler already does a full GC (including
clearing up objects waiting for finalizers) before it does the snapshot.

For the actual problem... if the objects are not within your control,
there's not a lot you can do about them. They may be freed during some
process in the .Net tabcontrol, ie: dispose or adding tabpages, etc. If they
are still around after you close the form, that's more of a problem.

Niall

Thank you Peter for responding.
I have the same problem even if i call GC.Collect().
-----Original Message-----
[email protected]:
[...]
tabCtrl.TabPages.Add(new TabPage());

we couldn't make out why they are getting created and why
not getting disposed.

Request any help on this issue.

Try calling GC.Collect() before taking the second memory sample. Normaly
the GC isn'T invoked immediately when you dispose an object. On Dispose
only unmanaged resources like filehandles get released. Memory is released
later when the GC is called.


--
------ooo---OOO---ooo------

Peter Koen - www.kema.at
MCAD CAI/RS CASE/RS IAT

------ooo---OOO---ooo------
.
 
Back
Top