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.
Have you tried just setting material.animated = false; before removing… it solved my leaks for MovieMaterials
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.
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?
Hey Dominic,
No I didn’t but I spoke with Ralph and think the latest rev has this correction.
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!
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.
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.
scene.removeChild(myDo3d);
^^ 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 !
Hey! :__ Finally I did it! My code was right but I had a wrong Papervision2 package version!
I´m doing a simple Arcade game andI will show u when I finish 
Thx guys :$ you really help me out
best regards!
Hey Clau,
Cool I’, glad you managed to solve it, and looking forward to seeing your work
[...] searched through the docs & internet for days trying to figure it out, eventually found this, which helped us along our [...]