Memory lekas...

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
coder89
Experienced Solver
Experienced Solver
Posts: 77
Joined: Fri May 23, 2008 9:01 am

Memory lekas...

Post by coder89 » Fri Jul 25, 2008 9:57 am

Hello.
I install "valgrind" on my Linux. I run it on my wxWidget application and I get few errors like this ones:
==15740== 12 bytes in 1 blocks are still reachable in loss record 16 of 189
==15740== at 0x4022AB8: malloc (vg_replace_malloc.c:207)
==15740== by 0x550E55B: _XlcCreateLC (in /usr/lib/libX11.so.6.2.0)
==15740== by 0x5530479: _XlcUtf8Loader (in /usr/lib/libX11.so.6.2.0)
==15740== by 0x5514F22: _XOpenLC (in /usr/lib/libX11.so.6.2.0)
==15740== by 0x5515062: _XlcCurrentLC (in /usr/lib/libX11.so.6.2.0)
==15740== by 0x5515326: XSupportsLocale (in /usr/lib/libX11.so.6.2.0)
==15740== by 0x5250092: _gdk_x11_initialize_locale (gdkim-x11.c:64)
==15740== by 0x52501A0: gdk_set_locale (gdkim-x11.c:102)
==15740== by 0x4FD8446: gtk_set_locale (gtkmain.c:1050)
==15740== by 0x45077C0: wxApp::Initialize(int&, wchar_t**) (in /usr/local/lib/libwx_gtk2ud_core-2.8.so.0.5.0)
==15740== by 0x48C647C: wxEntryStart(int&, wchar_t**) (in /usr/local/lib/libwx_baseud-2.8.so.0.5.0)
==15740== by 0x48C674B: wxEntry(int&, wchar_t**) (in /usr/local/lib/libwx_baseud-2.8.so.0.5.0)
==15740== by 0x48C6836: wxEntry(int&, char**) (in /usr/local/lib/libwx_baseud-2.8.so.0.5.0)
==15740== by 0x8055D3F: main (CoderCatApp.cpp:20)
==15740==
==15740==
==15740== 12 bytes in 1 blocks are still reachable in loss record 17 of 189
==15740== at 0x4022AB8: malloc (vg_replace_malloc.c:207)
==15740== by 0x550DD47: (within /usr/lib/libX11.so.6.2.0)
==15740== by 0x550E4F9: _XlcCreateLC (in /usr/lib/libX11.so.6.2.0)
==15740== by 0x5530479: _XlcUtf8Loader (in /usr/lib/libX11.so.6.2.0)
==15740== by 0x5514F22: _XOpenLC (in /usr/lib/libX11.so.6.2.0)
==15740== by 0x5515062: _XlcCurrentLC (in /usr/lib/libX11.so.6.2.0)
==15740== by 0x5515326: XSupportsLocale (in /usr/lib/libX11.so.6.2.0)
==15740== by 0x5250092: _gdk_x11_initialize_locale (gdkim-x11.c:64)
==15740== by 0x52501A0: gdk_set_locale (gdkim-x11.c:102)
==15740== by 0x4FD8446: gtk_set_locale (gtkmain.c:1050)
==15740== by 0x45077C0: wxApp::Initialize(int&, wchar_t**) (in /usr/local/lib/libwx_gtk2ud_core-2.8.so.0.5.0)
==15740== by 0x48C647C: wxEntryStart(int&, wchar_t**) (in /usr/local/lib/libwx_baseud-2.8.so.0.5.0)
==15740== by 0x48C674B: wxEntry(int&, wchar_t**) (in /usr/local/lib/libwx_baseud-2.8.so.0.5.0)
==15740== by 0x48C6836: wxEntry(int&, char**) (in /usr/local/lib/libwx_baseud-2.8.so.0.5.0)
==15740== by 0x8055D3F: main (CoderCatApp.cpp:20)
Do you know how to avoid of them? Becouse i'm trying to delete and deconstruct all possible objects and pointers and I still get this errors (33 errors) :(
Thanks for any help.

DavidHart
Site Admin
Site Admin
Posts: 4027
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart » Fri Jul 25, 2008 10:16 am

Hi,

If you look at those leaks, you'll see that the only mention of your own code is:
0x8055D3F: main (CoderCatApp.cpp:20)
After that it enters wx code, wxEntry, then wxApp, and then it descends into gtk, gdk and X11 code. So, even if there is a real leak at the bottom, it's nothing to do with you, nor with wxGTK.

Valgrind output can be confusing. I suggest you intentionally create a memory leak in your own code (e.g. wxChar* buf = new wxChar[100]; and don't delete it) so that you can see how valgrind shows it.

Regards,

David

coder89
Experienced Solver
Experienced Solver
Posts: 77
Joined: Fri May 23, 2008 9:01 am

Post by coder89 » Fri Jul 25, 2008 10:27 am

But here: "0x8055D3F: main (CoderCatApp.cpp:20)" I have only this code:

Code: Select all

//......
17: #include <wx/image.h>
18: //*)
19:
20: IMPLEMENT_APP(CoderCatApp);
21: 
22: bool CoderCatApp::OnInit()
23: {
//.......

DavidHart
Site Admin
Site Admin
Posts: 4027
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart » Fri Jul 25, 2008 12:48 pm

But here: "0x8055D3F: main (CoderCatApp.cpp:20)" I have only this code: IMPLEMENT_APP(CoderCatApp);
That's what I was trying to say. It's not your code, it's wx code; and the problem isn't even in the wx code, but deep within code called from there.

In other words, you don't have anything to worry about.

Post Reply