Memory Leak in .Net app

  • Thread starter Thread starter sqlnovice
  • Start date Start date
S

sqlnovice

I have an application that is using around 700MB and causing the memory leak.
I have used GC.Collect in some methods thought I need to force Garbage
Collection but the response time has increased than what it was before. I
tried to dispose objects that i could see but of no help. How can I check on
my machine my changes for any improvement in memory. What are the key
measurements I need to look for. any help is appreciated.
 
if GC.Collect() releases memory than your code is not disposing objects
correctly. if memory is still high, then you have static objects holding
resources or real unmanged code leaks. use windbg and sos.dll to debug.

-- bruce (sqlwork.com)
 
I have an application that is using around 700MB and causing the memory leak.
I have used GC.Collect in some methods thought I need to force Garbage
Collection but the response time has increased than what it was before. I
tried to dispose objects that i could see but of no help. How can I checkon
my machine my changes for any improvement in memory. What are the key
measurements I need to look for. any help is appreciated.

It is unwise to call GC.Collect unless you know what the consequences
of doing so are. For example, while the GC runs, nothing else runs.
Not your program, and not anyone else's program. That is possibly
what is slowing down the app. It is a rare and unusual situation in
which explicitly calling GC is needed or helpful.

The proper thing to do is correctly implement IDisposable in all
classes that use finite resources such as file handles or database
connections, and then always close database connections or files
immediately after use (and set the references to them to null). Then
the system will run the GC only if it ever needs to.
 
Back
Top