Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem with Dumping Object (new of MFC) and FreeLibrary

Problem with Dumping Object (new of MFC) and FreeLibrary

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelpc++performanceannouncement
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    leander
    wrote on last edited by
    #1

    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.

    N R A 3 Replies Last reply
    0
    • L leander

      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.

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      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 the new operator to allocate memory on the heap you will need to release it with the delete operator. It appears that the FreeLibrary *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

      1 Reply Last reply
      0
      • L leander

        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.

        R Offline
        R Offline
        Ranjan Banerji
        wrote on last edited by
        #3

        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.

        L 1 Reply Last reply
        0
        • L leander

          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.

          A Offline
          A Offline
          Alvaro Mendez
          wrote on last edited by
          #4

          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.)

          1 Reply Last reply
          0
          • R Ranjan Banerji

            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.

            L Offline
            L Offline
            leander
            wrote on last edited by
            #5

            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"

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups