Problem with Dumping Object (new of MFC) and FreeLibrary
-
I'm french, so I hope you will excuse me for my poor english. I have an MFC application which load lot of DLL. In this Dll I make allocation with new, so It use the MFC checking system for leak memory. And when I terminate my application, I free all my librairies with function 'FreeLibrary()'. But If I have some leak memory in a DLL the MFC Dumping Leak will display to me : Dumping Object-> #File Error#, etc.... I don't have the FileName. MFC can't find the name of the File (__FILE__) because the memory where the FileName where store was allocate in the DLL where the 'new' is made. So when I call the function 'FreeLibrary()' on my DLL, all memory which containt '__FILE__' were release. So how can I do to see my memory leak even if i have call FreeLibrary ? (I must call function FreeLibrary() otherwise I will have lot of problems with my application). Thanks you for reading my question.
-
I'm french, so I hope you will excuse me for my poor english. I have an MFC application which load lot of DLL. In this Dll I make allocation with new, so It use the MFC checking system for leak memory. And when I terminate my application, I free all my librairies with function 'FreeLibrary()'. But If I have some leak memory in a DLL the MFC Dumping Leak will display to me : Dumping Object-> #File Error#, etc.... I don't have the FileName. MFC can't find the name of the File (__FILE__) because the memory where the FileName where store was allocate in the DLL where the 'new' is made. So when I call the function 'FreeLibrary()' on my DLL, all memory which containt '__FILE__' were release. So how can I do to see my memory leak even if i have call FreeLibrary ? (I must call function FreeLibrary() otherwise I will have lot of problems with my application). Thanks you for reading my question.
leander wrote: So how can I do to see my memory leak even if i have call FreeLibrary ? (I must call function FreeLibrary() otherwise I will have lot of problems with my application). I am not biblically familiar with MFC as I had to lookup exactly what
FreeLibrary()
does. Anytime you use thenew
operator to allocate memory on the heap you will need to release it with thedelete
operator. It appears that theFreeLibrary
*only* handles ref counting and will unmap the module from the address space itself, I would belive that you still need to handle the internal allocation/deallocation of memory yourself. Hope this helps. :)
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
-
I'm french, so I hope you will excuse me for my poor english. I have an MFC application which load lot of DLL. In this Dll I make allocation with new, so It use the MFC checking system for leak memory. And when I terminate my application, I free all my librairies with function 'FreeLibrary()'. But If I have some leak memory in a DLL the MFC Dumping Leak will display to me : Dumping Object-> #File Error#, etc.... I don't have the FileName. MFC can't find the name of the File (__FILE__) because the memory where the FileName where store was allocate in the DLL where the 'new' is made. So when I call the function 'FreeLibrary()' on my DLL, all memory which containt '__FILE__' were release. So how can I do to see my memory leak even if i have call FreeLibrary ? (I must call function FreeLibrary() otherwise I will have lot of problems with my application). Thanks you for reading my question.
Cant you turn off FreeLibrary, only for so long as to find the memory leak? Also, Are the DLLs in debug mode? To completely debug the application, both your application and DLLs should be built in Debug mode.
-
I'm french, so I hope you will excuse me for my poor english. I have an MFC application which load lot of DLL. In this Dll I make allocation with new, so It use the MFC checking system for leak memory. And when I terminate my application, I free all my librairies with function 'FreeLibrary()'. But If I have some leak memory in a DLL the MFC Dumping Leak will display to me : Dumping Object-> #File Error#, etc.... I don't have the FileName. MFC can't find the name of the File (__FILE__) because the memory where the FileName where store was allocate in the DLL where the 'new' is made. So when I call the function 'FreeLibrary()' on my DLL, all memory which containt '__FILE__' were release. So how can I do to see my memory leak even if i have call FreeLibrary ? (I must call function FreeLibrary() otherwise I will have lot of problems with my application). Thanks you for reading my question.
I don't understand why failing to call FreeLibrary causes a lot of problems in your app. But that's what I would do: comment out the FreeLibrary calls (temporarily) and see if you can get a better reading on where the leaks are occurring. If that doesn't work, let me know and I'll help you find the leaks the hard way. X| Regards, Alvaro
Well done is better than well said. -- Benjamin Franklin (I actually prefer medium-well.)
-
Cant you turn off FreeLibrary, only for so long as to find the memory leak? Also, Are the DLLs in debug mode? To completely debug the application, both your application and DLLs should be built in Debug mode.
I try to turn off the call() to FreeLibrary() to Debug my leak, but it's little complicate to do it, because I have static object how make allocation with a memory manager (only for malloc and free, not for new and delete). So if I don't call the FreeLibrary the destructor off my static object is not call, and i have some crash when I free my memory manager. So for the moment, to debug leak, I remove the Freeliberary() and I don't release my memory manager to see the leak. But I hope to find an other solution without changing some code to with memory leak. My application and my DLL are compile in Debug with option "Multithread DLL"