Proper CEGUI shutdown / Valgrind

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

wondersye
Not too shy to talk
Not too shy to talk
Posts: 21
Joined: Sun May 22, 2011 16:04

Proper CEGUI shutdown / Valgrind

Postby wondersye » Fri Aug 12, 2011 21:20

Hi,

I was running Valgrind against a CEGUI-using program and saw a very large number of blocks that were still reachable (not true memory leaks). Indeed (like most available examples), no clean-up was down before halting the program. What is the recommended way of doing so with CEGUI? Are we supposed to remove all components (parser, scheme/font managers,resource providers, various singletons, etc.) each at a time, in reverse creation order? Is there a CEGUI::stop() or alike that I have missed?

Btw, Valgrind seems to hint at an error within mouse cursor management:

Code: Select all

==25267== Conditional jump or move depends on uninitialised value(s)
==25267==    at 0x5FDBF89: CEGUI::MouseCursor::constrainPosition() (CEGUIMouseCursor.cpp:183)
==25267==    by 0x5FDC1D3: CEGUI::MouseCursor::setConstraintArea(CEGUI::Rect const*) (CEGUIMouseCursor.cpp:221)
==25267==    by 0x5FDC405: CEGUI::MouseCursor::MouseCursor() (CEGUIMouseCursor.cpp:73)
==25267==    by 0x6007E42: CEGUI::System::createSingletons() (CEGUISystem.cpp:1504)
==25267==    by 0x600AF8E: CEGUI::System::System(CEGUI::Renderer&, CEGUI::ResourceProvider*, CEGUI::XMLParser*, CEGUI::ImageCodec*, CEGUI::ScriptModule*, CEGUI::String const&, CEGUI::String const&) (CEGUISystem.cpp:294)
==25267==    by 0x600B97C: CEGUI::System::create(CEGUI::Renderer&, CEGUI::ResourceProvider*, CEGUI::XMLParser*, CEGUI::ImageCodec*, CEGUI::ScriptModule*, CEGUI::String const&, CEGUI::String const&) (CEGUISystem.cpp:1891)
==25267==    by 0x55EFA8E: CEGUI::OpenGLRenderer::bootstrapSystem(CEGUI::OpenGLRenderer::TextureTargetType) (CEGUIOpenGLRenderer.cpp:121)


in:

Code: Select all

void MouseCursor::constrainPosition(void)
{
    Rect absarea(getConstraintArea());

    if (d_position.d_x >= absarea.d_right)
        d_position.d_x = absarea.d_right -1;
  [..]


Thanks in advance for any hint,

Olivier.

MarkR
Quite a regular
Quite a regular
Posts: 64
Joined: Thu Jul 15, 2010 06:55

Re: Proper CEGUI shutdown / Valgrind

Postby MarkR » Sat Aug 13, 2011 08:58

You should shutdown the system using the CEGUI::Renderer::destroySystem() method:

Code: Select all

CEGUI::OpenGLRenderer& renderer = CEGUI::OpenGLRenderer::bootstrapSystem();
...
renderer.destroySystem();


Haven't checked this for memory leaks, though.

wondersye
Not too shy to talk
Not too shy to talk
Posts: 21
Joined: Sun May 22, 2011 16:04

Re: Proper CEGUI shutdown / Valgrind

Postby wondersye » Sat Aug 13, 2011 20:59

Hello MarkR,

Thanks for your information, indeed this call improved a lot the situation.

Now the only still-reachable block I see that it is related to CEGUI is:

Code: Select all

==30421== 24 bytes in 1 blocks are still reachable in loss record 15 of 167
==30421==    at 0x4C28FAC: malloc (vg_replace_malloc.c:236)
==30421==    by 0x4007902: decompose_rpath (dl-load.c:569)
==30421==    by 0x4008512: _dl_map_object (dl-load.c:613)
==30421==    by 0x4012C7D: dl_open_worker (dl-open.c:226)
==30421==    by 0x400E745: _dl_catch_error (dl-error.c:178)
==30421==    by 0x40133F9: _dl_open (dl-open.c:555)
==30421==    by 0x8604F15: dlopen_doit (dlopen.c:67)
==30421==    by 0x400E745: _dl_catch_error (dl-error.c:178)
==30421==    by 0x860552B: _dlerror_run (dlerror.c:164)
==30421==    by 0x8604FC0: dlopen@@GLIBC_2.2.5 (dlopen.c:88)
==30421==    by 0x5FC1630: CEGUI::DynamicModule::DynamicModule(CEGUI::String const&) (CEGUIDynamicModule.cpp:110)
==30421==    by 0x600817A: CEGUI::System::setXMLParser(CEGUI::String const&) (CEGUISystem.cpp:1590)


I was using the default parser but tried nevertheless

Code: Select all

CEGUI::System::getSingleton().setXMLParser( /* XMLParser* */ 0 ) ;
before clean-up, this did not change the outcome.

Apart from this, at least on my minimal test case, CEGUI::Renderer::destroySystem() did the trick in terms of deallocation.

Thanks again,

Olivier.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: Proper CEGUI shutdown / Valgrind

Postby Kulik » Sat Aug 13, 2011 21:11

The unconditional jump that Valgrind reports here is already fixed in mercurial.

I am not sure why XMLParser is leaking at this point. In my test apps destroySystem does the trick.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 8 guests