[vtkusers] Memory leaks....
David Cole
david.cole at kitware.com
Mon Oct 30 08:27:57 EST 2006
You're welcome...
For reference of others reading this thread in the future, when you
use the /DELAYLOAD linker flag, you also need to link in DelayImp.lib
(as Han discovered) or provide your own implementation of the
delayLoadHelper function.
You also need to use the /DELAYLOAD flag explicitly for every dll that
you want delay loaded. In this case, that means any vtk dll that is
directly imported by the final app. The whole point being to ensure
that MFC's dll is loaded first and all vtk dlls loaded after that
point...
For others wanting to simply use this functionality, get the latest
VTK from CVS (or any snapshot after Oct. 18, 2006 -- fixes were
committed on Oct. 17...) And then follow the example MFC apps found in
VTK/Examples/GUI/Win32 : SampleMFC and vtkMFC.
Glad it worked!
David
On 10/30/06, echinococcus Multilocularis <lintworm2 at yahoo.co.uk> wrote:
>
> Thanks a lot! That did the trick! Also thanks again to David Cole!
>
> sincerely, Han
>
>
> ----- Original Message ----
> From: 이창원 <bosscq at nexgeo.com>
> To: echinococcus Multilocularis <lintworm2 at yahoo.co.uk>
> Cc: vtkusers at vtk.org
> Sent: Monday, 30 October, 2006 7:27:59 AM
> Subject: RE: [vtkusers] Memory leaks....
>
>
>
>
> Hello
>
>
>
> You have to delay load vtk dlls too. (such as vtkcommon, vtkrendering, etc)
>
>
>
> regards
>
>
>
> ________________________________
>
>
> From: vtkusers-bounces+bosscq=nexgeo.com at vtk.org
> [mailto:vtkusers-bounces+bosscq=nexgeo.com at vtk.org] On
> Behalf Of echinococcus Multilocularis
> Sent: Monday, October 30, 2006 6:37 AM
> To: David Cole
> Cc: vtkusers at vtk.org
> Subject: Re: [vtkusers] Memory leaks....
>
>
>
>
>
> Thank you for your response. I did what you suggested, to be precise, the
> second option. I added the linker option /DELAYLOAD:vtkMFC.dll. (I use
> vtkRendering.dll as well, should this one be delayed as well?) However, the
> result was now that there was an unresolved symbol:
>
>
>
>
>
> vtkMFC.lib(vtkMFC.dll) : error LNK2001: unresolved external symbol
> ___delayLoadHelper at 8
> Debug/VTKStart.exe : fatal error LNK1120: 1 unresolved externals
> Error executing link.exe.
>
>
> After a little googling, i noticed i should add the lib: Delayimp.lib. So i
> added the lib, and the compilation went fine again. However, now, the memory
> leaks returned. Is there something else wrong, or am i forgetting something?
>
>
>
>
>
> Secondly, if i were to go the other path, which files do I have to download?
> Only the files that are in the GUISupport/MFC/ or others as well?
>
>
>
>
>
> Thank you again for your response.
>
>
>
>
>
> Sincerely,
>
>
> Han
>
>
> ----- Original Message ----
> From: David Cole <david.cole at kitware.com>
> To: echinococcus Multilocularis <lintworm2 at yahoo.co.uk>
> Cc: vtkusers at vtk.org
> Sent: Sunday, 29 October, 2006 5:56:43 PM
> Subject: Re: [vtkusers] Memory leaks....
>
> The problem is that VTK dlls are loaded before the MFC dll, and at shutdown
> time, the MFC dll is unloaded before the VTK dlls... And when the MFC dll
> unloads, it does a memory leak check and incorrectly reports that all the
> VTK objects still left are leaks.
>
> You can overcome this by updating VTK to the CVS version and rebuilding VTK
> with VTK_USE_GUISUPPORT and VTK_USE_MFC turned on. I recently added flags
> to the CMakeLists to eliminate these false memory leak reports.
>
> Alternatively, you can use the /DELAYLOAD linker flag to force the VTK dlls
> to be loaded after the MFC dll and then they will also be unloaded prior to
> the MFC dll. Then any leak reports that you see will be for real... (This is
> what I added in CVS VTK to fix the problem.)
>
> HTH,
> David
>
>
>
>
> On 10/29/06, echinococcus Multilocularis <lintworm2 at yahoo.co.uk> wrote:
>
>
>
>
>
> Hello all,
>
> I finally got my M$ VC project working, using vtkMFCWindow. In this program
> i read some geometrical data from disk using my own readerfunction. I then
> display it using vtkMFCWindow. That all works fine, until i close the
> program and clean up the memory. At the end of program i get a message that
> memory leaks are detected. The problem is, that i really have no clue where
> they are from. When i look at the data dumped by VC, i find references to
> all kinds of objects i never have used. Can anybody tell me what i am doing
> wrong, or give me any other clues? I have build my program mostly using the
> examples given for vtkMFCWindow, however, also these examples give me the
> same problems.
>
> Thanking in advance,
>
> Han
>
> Send instant messages to your online friends http://uk.messenger.yahoo.com
>
>
>
> Send instant messages to your online friends http://uk.messenger.yahoo.com
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
More information about the vtkusers
mailing list