Clearing geometry cache for procedural geoms?

My current project uses procedurally-generated geometries for its level objects. The level object has one geomnode and one collision node, which are refreshed when the room changes by using removeAllGeoms() and clearSolids(). So far this has been working very nicely, but I may have run into a case where the geometry data is not being cleared from memory fully enough or quickly enough.

One of my in-game objects allows the player to burrow through the current level. This is done by revising the level map and recreating the geometry. While this process is being run, the FPS steadily decreases, finally returning to normal levels once the player stops moving and the “burrowing” process ends. If the player moves too quickly or changes screens too often while burrowing, the FPS never fully returns to its previous level. Based on some comments by dwrw relating to procedural geometry and memory handling, I assume this is due to the fact that Panda does not immediately clear the geometry cache from memory, but takes a cycle or two to do so. I assume that the slowdown results from modifying the geometry too quickly for Panda’s memory-clearing to catch up. Any lingering slowdown at the end, I assume, is because Panda was ultimately unable to clear some of the geometry from memory during the process, and something hasn’t been garbage-collected.

I am wondering if there is any way to clear this memory more effectively or more quickly, or to work with Panda’s limitations and avoid the problems I have been seeing. So far I can’t find any useful hints about this sort of thing on the forum, in the Panda documentation, or in the Python source code. Really, all I’ve been able to find is dwrw’s comments on the matter (for which I’ve lost the link…). Does anyone have any knowledge or experience that might help with this? :question:

For one, look into tho correct UsageHints enum value, eg. don’t set the data to UH_static, but more like UH_stream.

To release a Geom from video card memory, you can call geom.release_all().

Thank you, rdb. :smiley: I’m no longer seeing any lingering loss of FPS after the burrowing stops, with your changes in place. While the player is actively burrowing through the level, however, I do still see the drop in frame rate. This drop doesn’t seem to result in any problems with game play so far, but it can be a substantial drop. I’m seeing an average FPS decrease of 25% while the process is running. :open_mouth:

But I hadn’t realized there were options for this sort of thing. I will more carefully study the API listings for Geom and GeomNode. :slight_smile: