[wx-dev] Re: Problem or...?

Igor Korot ikorot at earthlink.net
Wed Nov 1 07:47:46 PST 2006


Francesco,

-----Original Message-----
>From: Francesco Montorsi <f18m_cpp217828 at yahoo.it>
>Sent: Nov 1, 2006 12:52 AM
>To: wx-dev at lists.wxwidgets.org
>Subject: [wx-dev]  Re: Problem or...?
>
>Igor Korot ha scritto:
>> Hi, ALL,
>> While trying to work on my program, I spotted a "problem".
>> Don't know if it's a serious one though...
>> 
>> To reproduce:
>> 
>> 1. In the config sample, change line 129:
>> "return true;" to "return false"
>> 2. Run the config sample program.
>> 3. Under the gdb it produces following:
>> 

[eaten]

>> However, I am not sure how to fix those leaks. Any ideas?
>running the program with valgrind:
>
>    valgrind --leak-check=full ./conftest
>
>usually is enough to spot any leak; note however that valgrind will show 
>you problems & leaks from anything used by your program, included X11 
>code and GTK code (which provoke a lot of "invalid read of 4 bytes" and 
>some GTK leak IIRC, and also a memleak of 26 bytes by wxSetEnv).
>
>However I haven't noticed any memory leak doing that true/false 
>substitution on my GTK+ 2.10.6 ... except obviously for the wxConfig 
>object which you create doing:
>
>  wxConfigBase *pConfig = wxConfigBase::Get();
>
>in OnInit() and which is never freed.

This is exactly what I meant.
Problem is that AFAIU, every single library/program should work gracefully in
hose situations: all allocated memory should be freed. OS will (theoretically?)
free this memory, but we, as a programmers will never know when.
Also, I would leave any system [GTK+] leaks behind, because they are almost
system leaks.
Besides MSW port will have only wxConfig leak, if not crash....

>
>In general returning false from OnInit() should only happen because of a 
>fatal error and I'm not sure how important is to avoid any memleak in 
>those cases...
>
>HTH,
>Francesco

Thank you.

>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: wx-dev-unsubscribe at lists.wxwidgets.org
>For additional commands, e-mail: wx-dev-help at lists.wxwidgets.org
>





More information about the wx-dev mailing list