Solved

DLL not being release from memory

Posted on 2003-11-18
7
165 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

688 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