Procedural Geometry Garbage Collection[SOLVED]

I’m creating a program where in I will be selecting points on a grid and dynamically generating line segments between those points using panda’s GeomLine primitives. My plan is to delete the existing custom geometry and make new geometry whenever a point is added, removed, etc. I want to verify that my code is going to garbage collect everything from the old geometry when I prepare to create new geometry. Here is the code I’m using:

	def clearSkeleton(self):
		self.skelVFormat = None
		self.skelVData = None
		self.skelVWrtr = None
		self.skelPrims = None
		self.skelGNode = None
		self.skelVFormat = GeomVertexFormat.getV3()
		self.skelVFormat = GeomVertexFormat.registerFormat(self.skelVFormat)
		self.skelVData = GeomVertexData("Skeleton VData", self.skelVFormat, Geom.UHStatic)
		self.skelVWrtr = GeomVertexWriter(self.skelVData, "vertex")
		self.skelPrims = []
		self.skelGeom = None
		self.skelGNode = GeomNode('gnode')

Will this remove all of the old geometry from memory completely and give me a new blank slate to work with?

Seems reasonable. Note that your old geometry will remain in Panda’s cache for a period of time after this, but it will eventually be removed.


Cool, thanks.

Is this means that clearing of geometry data before removeNode is wrong or unnecessary(clearRows(vertex data), clearVertices and clearPrimitives)? I`m getting a segfault and I found that clearing of data before removing node is the thing that causes this. My code is similar but I draw triangles.

Program received signal SIGSEGV, Segmentation fault.
0x0128673e in GeomPrimitive::get_data_size_bytes() const () from /usr/lib/panda3d/
(gdb) backtrace
#0  0x0128673e in GeomPrimitive::get_data_size_bytes() const () from /usr/lib/panda3d/
#1  0x01247027 in PreparedGraphicsObjects::release_index_buffer(IndexBufferContext*) () from /usr/lib/panda3d/
#2  0x011ccdaa in GeomPrimitive::release_all() () from /usr/lib/panda3d/
#3  0x011e15c6 in GeomPrimitive::~GeomPrimitive() () from /usr/lib/panda3d/
#4  0x011e1853 in GeomTriangles::~GeomTriangles() () from /usr/lib/panda3d/
#5  0x01297234 in Dtool_FreeInstance_GeomTriangles(_object*) () from /usr/lib/panda3d/
#6  0x00bf3ce6 in Dtool_Deallocate_General(_object*) () from /usr/lib/panda3d/
#7  0x0808db04 in dict_dealloc (mp=0x8d6ef0c) at ../Objects/dictobject.c:911
#8  0x0806a18b in instance_dealloc (inst=0x8d6c64c) at ../Objects/classobject.c:668

Clearing of geometry data is indeed completely unnecessary; it will be cleaned up automatically when the node goes away. Still, it shouldn’t cause a crash. That might be a bug, can you show a sample program that demonstrates the crash?


Sorry for my late answer. I have few days off. So today I found the problem and its not a panda bug. I have kept a references to all data(vertex data, primitive and geom). So, its wrong to modify data explicitly from these references(even for a cleaning only). :blush: