Solved

DLL not being release from memory

Posted on 2003-11-18
7
162 Views
Last Modified: 2010-05-03
I develop a program that use late binding to call a dll to load a form and release the dll once the form is loaded so that I can change or recompile the dll that is situated in the server even if the form is loaded in the client computer. The problem is the dll is not release after the form is loaded. It didn't even release after the client close the form. Do any of you guys know how can I go about it ?

my code is as follow;

Private Sub TreeView1_DblClick()
   
        ' late binding
       
        Dim objNew As Object
        Set objNew = CreateObject("InventorySystem.clsInventorySystem")

       'load the form base on what the use click on the treeview
        objNew.LoadForm Trim(TreeView1.SelectedItem.Text), strModuleMode

        ' release the object
        Set objNew = Nothing
       
End Sub
0
Comment
Question by:ericgan
  • 2
  • 2
7 Comments
 
LVL 29

Accepted Solution

by:
Nightman earned 145 total points
ID: 9770194
A little known issue with vb - while setting the object = nothing destroys the pointer to the object in memory, the object is not actually released until the calling application is terminated - this applies if you are late binding or if you have a project reference to the dll. I'm sorry, but I don't think there is an alternative.

Additionally, if the new version of the dll is not binary compatable with the old one, you will have to recreate the COM+ package and deploy it again on the client computers. The same goes if the interface has been extended.

Cheers
Night
0
 
LVL 9

Assisted Solution

by:_ys_
_ys_ earned 145 total points
ID: 9772462
Try invoking CoFreeUnusedLibraries:
Declare Sub CoFreeUnusedLibraries Lib "OLE32" ( )

t's typically not called by VB. This _may_ unload the dll for you - if all references to active objects have been released.

Rumours have it there's a 10 minute delay built in, but I'm not convinved.
0
 
LVL 29

Expert Comment

by:Nightman
ID: 10162678
Split point between Nightman and _ys_
0
 
LVL 9

Expert Comment

by:_ys_
ID: 10172601
I would be really interested to hear the result of the call to CoFreeUnusedLibraries. It's commanly called from good old C++ code, but as for VB code ... well, that's what I'm interested in.

Maybe ericgan can shed some light on this.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 10548685
Moderator, my recommended disposition is:

    Split points between: Nightman & _ys_

Dan Rollins -- EE database cleanup volunteer
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question