Strategy for detecting memory leaks in VB, ADO,net apps

J

JerryK

Hi,

We have a complex application that is experiencing a "memory leak". This is
not a traditional memory, since the application gives all the memory back at
terminate. Rather what we see i that the application continues to grow at
about 2 mbytes each time the same MDI form is open and closed. Eventually,
the OS starts trashing and displays the "your system is low on virtual
memory" message. Now I know the Garbage Collector is supposed to delay
collection, but I can hardly believe it waits this long.

So the question some up how can one monitor the various object creation and
destructions and see if something is preventing their collection. The
application makes use of ADO.net and uses the SQL Server connection manager
to talk to a SQL Server 2000 DB. The application is written in Visual
Basic.net. We are running the 1.1 .net framework.

At this point we will not ship the app because of this problem!

jerry
 
M

Marauderz

Check and see if you're dispoing any unneeded objects. I know that .Net is
supposed to have Garbage collection but I found that usually if you still
behave like a responsible programmer and dispose of everything that can be
disposed of. =P Especially images and large datasets. Cause sometimes you
don't orphan them properly and therefore the system thinks something is
still referencing it hence the object is never released.
 
J

John Saunders

Steve Drake said:
Setting object to null can help the GC, as it can work out quicker if they
are finished with.

Steve, this issue of "setting to null/Nothing" can be confusing for people
coming from a VB6 background, where it meant something similar, but
different. So, just to keep things clear for everyone - isn't it true that
this will only help the GC once it runs, but will not cause it to run any
sooner?

Also, we should try to be clear that the mechanism by which this assists GC
is very different than the mechanism of setting to Nothing in VB6. As an
example, assume you've got a class called BusinessObject which has a member
DBConnection which is an SqlConnection. Setting it to Nothing after you're
done with it helps the GC simply because the GC doesn't have to go looking
into the connection for more references - it can stop at "DBConnection". I
had the impression that the corresponding code in VB6 would decrement the
COM reference count and maybe even deallocate memory, which doesn't happen
in .NET.

I'd be willing to bet that in most cases, it costs more to set these things
to Nothing than it saves the GC.
 

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

Top