Re: [gnet-dev] Possible Memory Leak



So is there a leak in my code, or in gnet (unlikely, looking at its nice
cleanup code) or in glib (probably somewhere in the watch/source stuff?



you could try running it with valgrind to find it out.
I will check it myself when I boot my linux machine at home.

I experience the following:

1. valgrind does not like the glib mem profile functions, so I removed them.
2. the memory seems to be allocated in g_ptr_array_sized_new.
3. when I do instead

  context = g_main_context_default ();
  loop = g_main_loop_new (context, FALSE);

  ...

  g_main_loop_unref (loop);
  g_main_context_unref (context);

the leak disappears completely. So it is probably in the source handling of the main context and finally cleaned up. But then the static GMainContext *default_main_context is dangling nonzero inside glib, which is dangerous. Maybe propose a patch to g_main_context_unref to fix this?

4. In my _real_ gnet programs, valgrind says
==29743== warning: Valgrind's pthread_getschedparam is incomplete
==29743==          your program may misbehave as a result
And it does no longer respond to the Ctrl-D on stdin and network connects for example. Is there a possibility to fix this (redhat 9, glib 2.6.1)?

Carsten



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