Problem or...?
Francesco Montorsi
f18m_cpp217828 at yahoo.it
Wed Nov 1 00:52:11 PST 2006
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:
>
> igor at localhost ~/wxWidgets-2.7/buildGTK/samples/config $ gdb conftest
> GNU gdb 6.4
> Copyright 2005 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB. Type "show warranty" for details.
> This GDB was configured as "i686-pc-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1".
>
> (gdb) run
> Starting program: /home/igor/wxWidgets-2.7/buildGTK/samples/config/conftest
> [Thread debugging using libthread_db enabled]
> [New Thread -1224877488 (LWP 32022)]
> There were memory leaks.
>
> ----- Memory dump -----
> non-object data at 0x809AB40, size 60
> non-object data at 0x809ABB0, size 16
> non-object data at 0x809ABF0, size 56
> non-object data at 0x8132518, size 56
> non-object data at 0x8132580, size 64
> non-object data at 0x8131958, size 24
> non-object data at 0x81325F0, size 64
> non-object data at 0x8132700, size 12
> non-object data at 0x8132740, size 12
> non-object data at 0x8132688, size 24
> non-object data at 0x81327F8, size 12
> non-object data at 0x81328E0, size 56
> non-object data at 0x8132860, size 24
> non-object data at 0x8132948, size 64
> non-object data at 0x8132A80, size 12
> non-object data at 0x8132AC0, size 12
> non-object data at 0x8132A08, size 24
> non-object data at 0x8132B78, size 12
> non-object data at 0x8132BB8, size 24
> non-object data at 0x8132C78, size 12
> non-object data at 0x8132CB8, size 24
> non-object data at 0x8132D78, size 12
> non-object data at 0x813C690, size 24
> non-object data at 0x8172BF8, size 64
> non-object data at 0x8132DB8, size 12
>
>
> ----- Memory statistics -----
> 25 objects of class nonobject, total size 776
>
> Number of object items: 0
> Number of non-object items: 25
> Total allocated size: 776
>
>
>
> Program exited with code 0377.
>
> 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.
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
More information about the wx-dev
mailing list