Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Memory Leak Detector for VB.NET?

Status
Not open for further replies.

ProtocolPirate

Programmer
Nov 21, 2007
104
US
I ran the trial versions of Memory Validator and .NET Memory Profiler, but I couldn't get any useful information out of either. I have unmanaged code that I am marshaling data to and from which clearly has leaks, and I also have an OCX for scanning that has even bigger leaks. Whatever happened to good ol' Bounds Checker?
 
Is the mem leak in the program calling the unmanaged code, or in the unmanaged code?

Are you releasing your COM objects when you are done with them? if you are using a single form, that is consistently creating new COM objects then they are not being disposed of.

Code:
System.Runtime.InteropServices.Marshal.ReleaseComObject(o)

-Sometimes the answer to your question is the hack that works
 
I think that the leaks are in the marshaling. I'm calling a DLL for Btrieve (an old database) which I do not believe is a COM object. I downloaded the trial of GlowCode and got more information. I still can't get the line number of the leaks allocation, but I can at least get the function, and sure enough it is where I am marshaling. But also I'm getting leaks from calling WNetAddConnection2 in mpr.dll.
 
if you are referencing a dll and creating a object that is in the dll, then you are using a form of COM.

When you have done everything you need to do with the object, or on your objects dispose, run the line i gave you passing your object as the o

-Sometimes the answer to your question is the hack that works
 
That depends on whether the DLL is a COM DLL or a Win32 DLL.

If a COM DLL, then yes, you need to release your reference to it.

If a Win32 DLL, most likely not, but check the Platform SDK to make sure.

Chip H.


____________________________________________________________________
www.chipholland.com
 
Btrieve (and old database) is much older than COM. There are no COM objects here.
 
Well, without more details I(we) can't be of more help.

-Sometimes the answer to your question is the hack that works
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top