Can a nape system be completely disposed?

60 views
Skip to first unread message

Alex Op

unread,
Oct 10, 2016, 4:55:28 PM10/10/16
to Nape Physics
I am currently making a game in as3 using nape. My engine is based on "scenes". I have a "Menu" scene and a "GamePlay" scene. Whenever you switch a scene the old one disposes completely. Now the "GamePlay" scene initializes Nape like this "space = new Space(gravity)". Looking in Scout, at first nape initialization ~300-400kb are allocated (which is fine) but something does not garbage collect when I switch back to the "Menu" scene. If I don't initialize my nape space at all, everything disposes correctly. ( no bodies or other interaction is done with nape atm...just initializing an empty space)

Screenshot from scout at nape first initialization:









Alex Op

unread,
Oct 12, 2016, 10:49:09 AM10/12/16
to Nape Physics
Hello! I'm posting back here since i solved the issue. The problem was with the "ZPP" hidden classes, more precisely with the automatic object pooling of ZPP_Vec2. Whenever i was switching back and forth between scenes ("menu scene" <-> "game play scene"). The Vec2 pool was increasing with every switch ( and was never disposed). Using this disposal method helped releasing the pools from memory:

_physicsSpace.bodies.empty();
_physicsSpace.clear();
_physicsSpace = null;

Debug.clearObjectPools();

PS: Kudos to Luca for the speed, ease of use, and memory handling of this engine :D
Reply all
Reply to author
Forward
0 new messages