Papervision3d GW Memory Leak

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.

11 Responses to “Papervision3d GW Memory Leak”

  1. dizy Says:

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

  2. Idoru Says:
    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. Dominic Graefen Says:

    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. Idoru Says:
    Hey Dominic,
    No I didn’t but I spoke with Ralph and think the latest rev has this correction.
  5. Clau Says:

    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. Idoru Says:
    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. Clau Says:

    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. Idoru Says:
    :)
    scene.removeChild(myDo3d);
  9. Clau Says:

    ^^ 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. Clau Says:

    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. Idoru Says:
    Hey Clau,
    Cool I’, glad you managed to solve it, and looking forward to seeing your work :)

Leave a Reply