Menu

#123 memory leaks on termination of TestPluginRunner UI

1.10.2
open-remind
nobody
UI - Other (6)
5
2009-11-24
2004-06-21
No

Platform: WinXP Prof. SP 1
Complier: Visual .Net 2003 C++ ver 7.1.3088

I'm getting memory leaks from 'TestPlugInRunner' --
have i missed a buld step for .Net?

Steps to reproduce:
0. Unzipped CppUnit 1.10.2
1. Built example solution (default conversion from v6.0
workspace provided) debug mode.
2. Run TestPlugInRunner in debugger
3. Choose and open 'simple_plugind.dll'
4. Close TestPluginRunner

Results (debug output):
The thread 'Win32 Thread' (0x914) has exited with code
0 (0x0).
Detected memory leaks!
Dumping objects ->
{292} normal block at 0x00329BE8, 48 bytes long.
Data: < 2 2 2 > 10 99 32 00 10 99 32 00 10 99
32 00 CD CD CD CD
{291} normal block at 0x00329BA8, 20 bytes long.
Data: < 2 2 2 > A8 9B 32 00 A8 9B 32 00 A8 9B
32 00 CD CD CD CD
{290} normal block at 0x00329B50, 44 bytes long.
Data: < 4 2 > F0 34 04 10 CD CD CD CD A8 9B
32 00 00 00 00 00
{289} normal block at 0x00329910, 48 bytes long.
Data: < 2 2 2 > E8 9B 32 00 E8 9B 32 00 E8 9B
32 00 CD CD CD CD
Object dump complete.
The program '[2328] TestPlugInRunnerd.exe: Native' has
exited with code 0 (0x0).

Note:
The errors don't occur unless a 'dll' is loaded.. running
the dll test set does not effect the error.
The error occurs on process termination (after unloading
the test 'dll' and terminating process threads).

Discussion

  • aioaneim

    aioaneim - 2009-07-03

    Hello!

    This happens due to order of unloading dlls in Windows in relation with static variables destruction. First the PlugIn dll is unloaded, and then some destructors which belong to the memory space just released by the former dll are called.

    The bottleneck sits in the TestFactoryRegistry.cpp file and it is regarding how the internal class TestFactoryRegistryList has implemented the Singleton pattern.

    static TestFactoryRegistryList *getInstance()
    {
    static TestFactoryRegistryList list;
    return &list;
    }

    I have exposed externally this TestFactoryRegistryList class by moving to another file and also moving into it some functions which are now exposed by the TestFactoryRegistry class which by the means of the being visible externally.
    I have implemented the Singleton with a static pointer variable in the classical way, and with 2 functions, getInstance and releaseInstance. Before unloading the DLL, I call the releaseInstance when the ul_reason_for_call == DLL_PROCESS_DETACH condition is met. (I have modified also the CPPUNIT_PLUGIN_IMPLEMENT_MAIN macro in the TestPlugIn.h file. You have to call this method manually if you write your DllMain function.

    Some small adjustments in the code are needed in order to compile, nothing very complicated.

    I did not make all the tests but this can be a good starting point in redesigning this part because it is ugly to always see in your output a lot of memory leaks, you’ll never know if they are coming from CppUnit or they are your faults.

    Marian Aioanei

     
  • Baptiste Lepilleur

    • status: open --> open-remind
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.