Memory Leak in .Net app

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.
 
B

bruce barker

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)
 
H

harborsparrow

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.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,701
Latest member
XavierQ83

Latest Threads

Top