Re: memory leaks ( previous thread )



Chirstopher,

Hmmmmmm....

Well, two things. First off, hopefully someone more knowledgeable
(Where's Murray?) will chip in and offer an explanation.

Perhaps try making your dll function create and destroy a widget
instead of creating the Gtk::Main object.  Perhaps, the Main object
creates some sort of static memory that isn't being freed when you
close the dll.

You could just create a single Main object that stays in your code and
then you load your windows dynamically.

Secondly, what you're doing is kind of, well, weird. If what you want
is to periodically attach a gui to some process that's running in the
background, I'd suggest using socket I/O.

I'm actually getting ready to start a project that does the whole
background process that allows attaching a gui and I'm planning on
using sockets.  They have the added benefit that you can write console
based frontends, frontends in other languages and loads and loads of
other neat things.

And for the same project but in a different application I plan on
doing the loading gui components from shared libraries.

I just can't see that loading the entire GUI system periodically would
be a Good Thing (TM).

I guess none of thats really useful for fixing the problem, but we can
still hope that Murray or one of the other guys has an idea...

Paul

On 12/6/06, Christopher Raine <c raine gmx net> wrote:

I am sorry that I cannot reply to the thread created by Trigve Siver
directly, I have just joined the mailing list.

I am currently evaluating gtkmm for use in our current project and
have encountered the same memory leaks Trigve Siver has reported
under WinXP/VS2005, latest gtkmm stable release. From my expierience,
the memory leaks reported by the crt-debugging functions are valid.

Considering the application structure we already have and the
requirements we must meet, we intend to use gtkmm to build an UI that
resides in an implicity linked DLL which can be loaded and unloaded
at runtime. Therefore I have changed the code snippet posted in the
previous thread to the following :

#include <windows.h>
#include <crtdbg.h>

typedef void (*PC) (int argc, char *argv[]);

int main(int argc, char *argv[])
{
        _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF  );

        for ( int x = 0; x<100; x++ ) {
                HMODULE hDll = ::LoadLibrary(L"test_dll.dll");

                PC pc = (PC) ::GetProcAddress(hDll,"gtkmm_test" );
                pc(argc, argv);

                ::FreeLibrary( hDll );
        }
     return 0;
}

The "gtkmm_test" is a static function exported from the test_dll.dll
and is defined as follows :

extern "C" __declspec(dllexport) void gtkmm_test( int argc, char *argv
[] )
{
            Gtk::Main kit(argc, argv);
}

If you execute the above, the amount of memory that is reported by
the crt debug function increases as well as the total memory usage.
Sadly, for us at least, the reported memory leaks are valid.

I have uploaded the sources for my test program ( VS2005 required )
for verification under :
http://rainestorm.org/craine/gtkmm_memleak.zip

regards,
Christopher Raine



_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]