Results 1 to 4 of 4

Thread: Qt dll + memory leak

  1. #1
    Join Date
    Jul 2007
    Location
    BY.Minsk
    Posts
    90
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Qt dll + memory leak

    for example:

    Qt Code:
    1. //Qt dll - H
    2. class DLL_EXPORT ScriptEngine
    3. {
    4. public:
    5. ~DLL() {}
    6. DLL() {}
    7.  
    8. bool SomeFunction(LPCTSTR);
    9.  
    10. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. //Qt dll - CPP
    2. DLL::SomeFunction(LPCTSTR cStr);
    3. {
    4. //If this cause any Qt function or initialize Qt class
    5. //in the Win32 application, I get a memory leak!
    6. }
    To copy to clipboard, switch view to plain text mode 


    Win 32 MFC project:
    (All are linked without any problem)
    Qt Code:
    1. ...
    2. #include "dll.h"
    3. #pragma comment(lib,"../debug/dll.lib")
    4.  
    5. ....
    6.  
    7. DLL *a;
    8. a = new DLL;
    9.  
    10. a->SomeFunction(...);
    11.  
    12. if (a != NULL)
    13. delete a;
    To copy to clipboard, switch view to plain text mode 

    After closing the application window output MSVS see:
    for example:

    Qt Code:
    1. Detected memory leaks!
    2. Dumping objects ->
    3. {186} normal block at 0x007B8750, 24 bytes long.
    4. Data: < > 00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00
    5. {185} normal block at 0x007B86A8, 104 bytes long.
    6. Data: < #g` { U2g> F4 B1 23 67 60 86 7B 00 00 00 00 00 E8 55 32 67
    7. {184} normal block at 0x007B8660, 8 bytes long.
    8. Data: < #g { > 00 B2 23 67 A8 86 7B 00
    9. {183} normal block at 0x007B8608, 24 bytes long.
    10. Data: < > 00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00
    11. {182} normal block at 0x007B85B0, 24 bytes long.
    12. Data: < > 00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00
    13. {181} normal block at 0x007B8538, 56 bytes long.
    14. Data: < ` { > 01 00 00 00 60 86 7B 00 00 CD CD CD 00 00 00 00
    15. Object dump complete.
    16. The program '[4884] Test.exe: Native' has exited with code 0 (0x0).
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt dll + memory leak

    Well, it happens that Qt might initialize some global stuff that is not released when you delete your class.
    Unloading the .dll might cause that memory to be freed (or not).

  3. #3
    Join Date
    Jul 2007
    Location
    BY.Minsk
    Posts
    90
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt dll + memory leak

    Quote Originally Posted by caduel View Post
    Well, it happens that Qt might initialize some global stuff that is not released when you delete your class.
    Unloading the .dll might cause that memory to be freed (or not).
    And how to unload all that was initialized in the library prior to her discharge?
    In fact, a memory leak is even simple initialization QString c and given a line of any text.

  4. #4
    Join Date
    Jul 2007
    Location
    BY.Minsk
    Posts
    90
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt dll + memory leak

    After the experiments - found that the memory leak only occurs in debug mode. In the release - this is not. But the same should not be!
    What can recommend?

Similar Threads

  1. Memory leak detection
    By Sid in forum Qt Programming
    Replies: 8
    Last Post: 4th May 2011, 22:38
  2. memory leak question
    By cool_qt in forum General Programming
    Replies: 3
    Last Post: 20th January 2009, 07:49
  3. Memory leak weirdness
    By Darhuuk in forum General Programming
    Replies: 10
    Last Post: 10th January 2008, 18:51
  4. QPixMap and Memory leak
    By Krish_ng in forum Qt Programming
    Replies: 1
    Last Post: 7th August 2007, 14:18
  5. Memory Leak in my Application :-(
    By Svaths in forum Qt Programming
    Replies: 4
    Last Post: 27th July 2007, 19:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.