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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLL Memory leaks

Status
Not open for further replies.

Naftali

Programmer
Feb 14, 2001
17
0
0
IL
Hello All,

We have a serious problem of memory leaks in our application that is caused because the fact that even when the application goes down the Dll's that it's using are still in the air (when we did restart to the computer the dll gave us an error message).
We want to know how can we see in the application which dll's are still in the air and how can we "kill" those dll's from inside of the application.

Thanks in advance,

Naftali.
 
They should unload if you set them to nothing, something like:

On error goto errhndl:

exit sub
ErrHndl:
Set MyDllObject = nothing
unload me 'and other objects
end
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Which DLL's are causing you problems. Are they your own written DLL's or third party ones?

Are the DLL's Object libraries or system API's ?

As far as object libraries are concerned, they will only unload when the last reference to them has been destroyed. You must ensure that all created objtect are set to nothing when you exit your application.

Chris Dukes
 
Hi All,

I wish it was that simple. The problem is we are setting everything to Nothing and still have problem which means that even though we set to nothing there is still something that holds refernce to those Dll's(Own & third party - we have both), therefore we want to find a way that we can get the ID of the process of the Dll so we can terminate it "manually".

So, if you have any ideas, I'll be more than greatful...
 
1) check your program through and through for circular references, or references to objects and controls on other forms (frmMain!txtBox == slap on the wrist! :) )

2) eliminate any and all usage of "End"

3) make an inventory of the 3rd party controls you are using and search the company's support pages and/or knowledge base for info on possible memory leaks using their controls

4) download one of several free "Process Viewer" or "Thread Viewer" type utilities floating around and observe your program in action.

5) is your program doing anything that would be considered asynchronous? Such as an asynchronous query, an out of process DLL, ActiveX EXE, or some funky threading stuff using API calls?

6) check any usage in your program of "Exit Sub" "Exit Property" or "Exit Function". It could be bypassing code necessary to release certain objects.

7) if you have code setting stuff to Nothing, make sure it is always in the Unload event on forms, or Terminate event in classes

8) are you having a problem with several DLLs or just one in particular? If it is just one you could even add code to write to some type of log file every time a particular class or control is created & destroyed and track usage that way.

Good Luck
Adam
 
One more thing to check for is "Do Events". Many developers use it to simulate multi-threading, and if you aren't disciplined in it's use, you can have problems.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top