[Linux-ha-dev] Re: [Linux-ha-cvs] Linux-HA CVS: lib by zhenh from
Guochun Shi
gshi at ncsa.uiuc.edu
Fri Aug 12 13:25:25 MDT 2005
thanks, same problems exist in GSource.c
I will change it.
-Guochun
At 01:51 PM 8/12/2005 +0800, you wrote:
>Hi,
>
>In glib, only the ref_count of source reduced to zero, the memory of source would be released.
>The Gmain_timeout_add() calls g_source_new() to create the source, which ref_count = 1,
>and then calls g_source_attach() that increse the ref_count again.
>So the Gmain_timeout_add() returns a tag to a source whose ref_count is 2.
>However, the previous Gmain_timeout_remove() only call g_source_destroy() once.
>This cause the memory of GSource lost (64 bytes).
>I have catched the situation by add debug code to cl_malloc() and cl_free().
>
>So please make sure that using Gmain_timeout_remove() instead of g_source_remove() to release the tag got from Gmain_timeout_add().
>g_source_remove() will cause the same problem.
>
>linux-ha-cvs at lists.linux-ha.org wrote:
>
>>linux-ha CVS committal
>>
>>Author : zhenh
>>Host : Project : linux-ha
>>Module : lib
>>
>>Dir : linux-ha/lib/clplumbing
>>
>>
>>Modified Files:
>> Gmain_timeout.c
>>
>>Log Message:
>>fix a memory leak, Gmain_timeou_add would increase 2 to source->ref_count, but Gmain_timeout_remove only reduce 1
>>===================================================================
>>RCS file: /home/cvs/linux-ha/linux-ha/lib/clplumbing/Gmain_timeout.c,v
>>retrieving revision 1.12
>>retrieving revision 1.13
>>diff -u -3 -r1.12 -r1.13
>>--- Gmain_timeout.c 4 Aug 2005 02:15:04 -0000 1.12
>>+++ Gmain_timeout.c 12 Aug 2005 05:09:09 -0000 1.13
>>@@ -1,4 +1,4 @@
>>-/* $Id: Gmain_timeout.c,v 1.12 2005/08/04 02:15:04 horms Exp $ */
>>+/* $Id: Gmain_timeout.c,v 1.13 2005/08/12 05:09:09 zhenh Exp $ */
>>/*
>> * Glib mainloop timeout handling code.
>> *
>>@@ -102,6 +102,7 @@
>> GSource* source = g_main_context_find_source_by_id(NULL,tag);
>>
>> if (source != NULL){
>>+ g_source_unref(source);
>> g_source_destroy(source);
>> }
>>
>>
>>
>>_______________________________________________
>>Linux-ha-cvs mailing list
>>Linux-ha-cvs at lists.linux-ha.org
>>http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs
>>
>>
>
>
>--
>Best Regards,
>Huang Zhen
>Linux Technology Center IBM China Development Lab, Beijing
>Telno: (8610)82782244-2845
>_______________________________________________________
>Linux-HA-Dev: Linux-HA-Dev at lists.linux-ha.org
>http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
>Home Page: http://linux-ha.org/
More information about the Linux-HA-Dev
mailing list