“Be inspired, enjoy your work, keep learning and never forget to play.” — gskinner

Papervision3d GW Memory Leak

Posted: February 19th, 2008 | Author: Idoru | Filed under: 3D, Actionscript3, Papervision3d, WorkAround | 12 Comments »

Yesterday I came across a nasty leak with GW, it just wouldn't kill my moviematerials after I removed all the references to them, I tried it all, removeChild, removeListener, weak keys... you name it.

So I finally decided to go have a look at Papervision's destroy methods, and surprise surprise they weren't being called, no harm there, it's alpha these things are meant to happen :)

So here's what you have to do to force those destroy methods to execute, and clean your memory.

In org.papervision3d.core.proto.MaterialObject3D  set the destroy method from protected to public, do the same to all the materials that you use, like org.papervision3d.materials.MovieMaterial . When you're done with these just the destroy method in your class. For me it looks something like this:

Hope this helps.


12 Comments on “Papervision3d GW Memory Leak”

  1. 1 dizy said at 3:16 am on February 28th, 2008:

    Have you tried just setting material.animated = false; before removing… it solved my leaks for MovieMaterials

  2. 2 Idoru said at 8:40 am on February 28th, 2008:

    Hi dizy, well the problem is that setting material.animated, doesn’t remove it from memory properly, you might still end-up with some reference as the Engine doesn’t and won’t call the destroy method.

  3. 3 Dominic Graefen said at 4:34 am on May 17th, 2008:

    Hey,
    i had a few of these gc problems with pv3d as well.
    In some cases PV3D keeps very strong reference :(
    Did you put it in the PaperVision-IssueTracking on google Code?

  4. 4 Idoru said at 8:04 am on May 17th, 2008:

    Hey Dominic,
    No I didn’t but I spoke with Ralph and think the latest rev has this correction.

  5. 5 Clau said at 9:12 am on June 25th, 2008:

    Hi guys, I´m trying to delete objects as you said but when I request the scene numChildren it´s giving me the same amount of objects than before destroying them, any ideas?
    I ´d really appreciate any comments
    Thx!

  6. 6 Idoru said at 9:23 am on June 25th, 2008:

    well after you remove them from the scene, it might not be immediate, you might have to wait for the next frame cycle to complete to see changes, try using the profiler to check this out.

  7. 7 Clau said at 7:43 am on June 26th, 2008:

    Idoru thx, but it didn´t work at all, how do you use to remove the objects from the scene? A piece of code would be very appreciate.

  8. 8 Idoru said at 8:02 am on June 26th, 2008:

    :)
    scene.removeChild(myDo3d);

  9. 9 Clau said at 10:34 am on June 26th, 2008:

    ^^ ok!
    But the problem is that.. even the objects dissapear from the scene, they´re still there!! I mean, if you´re creating and deleting Planes for a while the scene.numChildren will grow up until the program crash!:P I need a way to create and delete objects for real,
    any ideas? Am I wrong about at any Point? thx !

  10. 10 Clau said at 10:58 am on June 26th, 2008:

    Hey! :__ Finally I did it! My code was right but I had a wrong Papervision2 package version!
    Thx guys :$ you really help me out :) I´m doing a simple Arcade game andI will show u when I finish :)
    best regards!

  11. 11 Idoru said at 6:50 pm on July 2nd, 2008:

    Hey Clau,
    Cool I’, glad you managed to solve it, and looking forward to seeing your work :)

  12. 12 Material Memory Leak Issue In Papervision3D | DestroyYourComputer.com | Blog - Interactive Design Agency said at 3:45 pm on October 8th, 2009:

    [...] searched through the docs & internet for days trying to figure it out, eventually found this, which helped us along our [...]


Leave a Reply