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!

Check DLL is cleared from memory?

Status
Not open for further replies.

MrPeds

Programmer
Jan 7, 2003
219
GB
Hi,

I invoke a DLL from my VB 6 project. It carries out the job it is supposed to do first time round, but I not convinced that the DLL is performaing its memory management code correctly when it completes execution.

Therefore, is it possible in VB to test, or ensure that after each call to the DLL is made the DLL's memory footprint is completely removed e.g. perform a double check to clean it up if it hasn't.

I did wonder if there was an opposite function to AppActivate (or similar) to deactivate code, but the realised that this function deals with applications and not DLL's.

Any help would be appreciated,

Thanks.

MrPeds
 
thanks for this, i will let you know how i get on in a day or so!

Thanks

MrPeds
 
Just out of curiousity I ran Task Manager and looked at if the Application and individual processes increased/decreased as is expected. This did happen.

Therefore, does VB manage memory differently to C++?

I wrote a simple program in C++ that calls the DLL function. If i keep executing this C++ application time after time it works fine.

However, as I mentioned above, if I keep executing the DLL function by pressing my button on the form it works fine first time, but after this the Dialog displays but doesn't refresh its status bar or other results.

(The DLL I call has one function that returns an integer. The actual code displays an MFC Dialog written in C++ that displays a status bar and carries out some calculations in the background, then displays the results). I think that a thread is used to control the progress bar so it could also be a thread problem e.g. not terminating properly.)
 

This is a relatively new area for me too.

Without seeing your code I have to ask, did you set your object to nothing each time ? or only on the unload ?

sub button_click()
dim objMydllCall as MyDllCall

set objMydllCall = new MydllCall
objMydllCall.dowhatever
objMydllCall.close
set objMydllCall = nothing

end sub

 
robk54,

At the top of the form I make a function declaration as follows:

Declare function myFunction lib "my_dll.dll" () as Integer

in the buttons event handler i do the following:

Sub button_click()

Dim result As Integer

result = myFunction()

if result <> 0 then
MsgBox(&quot;There has been an error&quot;)
end if

End Sub

Could the way I declare and use the function be error??

Thanks,

MrPeds
 

MrPeds

sorry about that last one - I was mixed up with referencing an object !
My guess is that vb allocates the memory on the declare statement & doesnt release it until the form is unloaded or the app is closed.

Is this a big issue ? or are you just interested ?
I will ask around.

Rob
 
Robk54,

I'm not too worried about the mechanics of how VB manages memory, its just the issue to do with the DLL not working properly when it is invoked second, third, or fourth etc time around as mentioned earlier in the thread.

When I re-start the application it works fine so your theorey about the declare statement could be the solution.

I would need to somehow to end the application, re-start it at the appropriate form and it should work fine. I just need to work out how to do this!

MrPeds
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top