Solved

DLL not being release from memory

Posted on 2003-11-18
7
160 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
Comment Utility
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
Comment Utility
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
Comment Utility
Split point between Nightman and _ys_
0
 
LVL 9

Expert Comment

by:_ys_
Comment Utility
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
Comment Utility
Moderator, my recommended disposition is:

    Split points between: Nightman & _ys_

Dan Rollins -- EE database cleanup volunteer
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now