Page 1 of 4 1234 LastLast
Results 1 to 10 of 34

Thread: Collada DOM memory leak issue.

  1. #1
    Junior Member
    Join Date
    Feb 2006
    Location
    Toronto, Ontario, Canada
    Posts
    5

    Collada DOM memory leak issue.

    I am new to Collada/DAE and I am wondering if I am doing something wrong or if there are memory leaks in the DOM.

    In my application I have the following:

    Code :
    DAE* daeObject = new DAE;
    daeObject->cleanup()  // I have tried without this as well
    delete daeObject;

    There are a ton of memory leaks when I do this, am I supposed to shut down some other way?

    Thanks!

  2. #2
    Senior Member
    Join Date
    Aug 2005
    Location
    California
    Posts
    165
    No you aren't doing anything wrong... the code is just (edit: I removed my flaming since I was wrong in my assumptions when I wrote this post)
    I see whats going on I'll have this fixed, well maybe not all the memory leaking but definately a large majority of it, for the release of COLLADA 1.4 DOM Patch 1 which will hopefully be released by the end of the day today.

    -Andy

  3. #3
    Senior Member
    Join Date
    Aug 2005
    Location
    California
    Posts
    165
    Actually.. Upon further inspection you are doing something slightly wrong.

    dae::cleanup() is a static function and it is actually useless to call it from a non static context.

    The proper way to exit your program would be to call
    Code :
    DAE* daeObject = new DAE;
    delete daeObject;
    DAE::cleanup();

    -Andy

    Heres further explanation if you care about these details.
    The first line in cleanup checks the DAEInstanceCount. If it is not 0 then it will not delete the static meta information which is causing your leak.
    In the destructor the DAEInstanceCount is decremented. That is why you must call it statically after you delete your pointer to the DAE object.

  4. #4
    Junior Member
    Join Date
    Feb 2006
    Location
    Toronto, Ontario, Canada
    Posts
    5
    Thanks very much alorino as that solved this problem and it now cleans up properly when I instantiate and delete the object. My second problem is that I'm wondering how to clean everything up.

    Code :
    DAE* daeObject = new DAE;
    daeObject->load( "file:///cube.dae" );
    delete daeObject;
    DAE::cleanup();

    I get memory leaks as I guess cube.dae stays loaded. What do I have to do to clean up after this?

    Thanks for your time.

  5. #5
    Junior Member
    Join Date
    Mar 2006
    Posts
    21
    me too, i have too many leaks, is it from collada or us?

    Code :
    DAE* dae = new DAE();
    dae->load("test_tex.xml");
    dae->unload("test_tex.xml");
    delete dae;
    DAE::cleanup();

  6. #6
    Junior Member
    Join Date
    Aug 2004
    Posts
    7
    Quote Originally Posted by alorino
    Actually.. Upon further inspection you are doing something slightly wrong.

    dae::cleanup() is a static function and it is actually useless to call it from a non static context.

    The proper way to exit your program would be to call
    Code :
    DAE* daeObject = new DAE;
    delete daeObject;
    DAE::cleanup();

    -Andy

    Heres further explanation if you care about these details.
    The first line in cleanup checks the DAEInstanceCount. If it is not 0 then it will not delete the static meta information which is causing your leak.
    In the destructor the DAEInstanceCount is decremented. That is why you must call it statically after you delete your pointer to the DAE object.
    I don't see why DAE::cleanup() needs to be public or called. When I delete my last DAE object it should automatically clean up. Instead of:
    Code :
    DAE* daeObject = new DAE;
    delete daeObject;
    DAE::cleanup();
    I'd prefer to:
    Code :
    {
    DAE daeObject;
    }
    And have it all clean up when my object is deleted for going out of scope. I see no reason to have to call cleanup().

    Cheers,

    Rich

  7. #7
    Junior Member
    Join Date
    Mar 2006
    Posts
    21
    When I make a DAE::Cleanup(), the DAEInstanceCount is 0 and there is still leaks :'(

  8. #8
    Junior Member
    Join Date
    Mar 2006
    Posts
    4
    Quote Originally Posted by Kinju
    When I make a DAE::Cleanup(), the DAEInstanceCount is 0 and there is still leaks :'(
    Unfortunately he's right. It seems that the memory that the collection has allocated never gets released. I kinda debugged the COLLADA DOM and found out that DAE::unload() doest the same thing as daeDatabase:removeCollection(). The removeCollection code thou just removes the collection from the two vector arrays, but doesn't free the memory that has been allocated from the previous create collection in the createCollection method. Now i hate to say this, but i didn't find any reference counters that will delete the memory that a collection has allocated in DAE::cleanup(). As i found out, the right thing to do so that the memory leaks won't show up is to get the collection pointer and delete itself. Which unfortunately has the really bad habit of deleting the elements, which leads to a crash in a later load when the DOM library tries to resolve all the elements with daeElement::resolveAll(), because they are deleted, but still in the static array of loaded elements.

    I'm pretty sure that i'm not using the library in the intended way and probably have a really bad hacks that lead to my load crashes. But then again, i can't seem to find them, wrote everything as it was in the programming guide but still trying to remove the memory leaks leads to a crash.

    To be honest i'm still struggling with COLLADA DOM and will continue trying to overcome all of its problems, just because the library has the potential to be really good i really don't wont to spend 2 months in writting my own DOM parser of COLLADA just because the one provided here has a few bugs that still need to be fixed. And i'll do my best to feedback any information regarding the bugs i find, so that they can be fixed as fast as possible.

  9. #9
    Senior Member
    Join Date
    Aug 2004
    Location
    California
    Posts
    771
    COLLADA DOM bugs should be reported to the project's bug tracker.

    COLLADA DOM Bug Tracker

    Thanks,
    Marcus

  10. #10
    Junior Member
    Join Date
    Apr 2006
    Posts
    27
    I have the same problem, the static array (ResolveArray) is never freed. Do you find a solution ? It's really annoying...

Page 1 of 4 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •