Hi Glen, I have modified your program below to delete the geometry objects. You simply delete the current geometry object (pointed by gGeometry) The TGeometry destructor will take care of deleting all nodes/shapes/ materials/matrices. Rene Brun Glen R. Salo wrote: > > Hi, > > I'm trying to figure out how to delete the geometry shape objects. I've tried > many thing, but I have not been able to completely remove memory leaks. Below > is a sample code of what fails and how I am approaching the problem. > > Thanks for all of your help. > > #include "TROOT.h" > #include "TBRIK.h" > #include "TTUBE.h" > #include "TNode.h" > #include "TApplication.h" > #include "TCanvas.h" > #include "TRotMatrix.h" > > extern void InitGui(); > VoidFuncPtr_t initfuncs[] = {InitGui, 0}; > > TROOT root("Test","Test",initfuncs); > > void create_wire( TNode *topNode ); > > int main(int argc, char **argv) { > > TBRIK *brick; > TNode *topNode; > TCanvas *c1; > > TApplication geomApp("testApp", 0, NULL); > > c1 = new TCanvas("c1","TestClass",500,500); > > // This loop shows how memory usage grows. > for (int i = 0; i < 200000; i++) { > > if ( i != 0 ) { > // How do I delete all of the existing geometry shape, node, and rotation > // matrix objects? I wish it would be as simple as the following line. delete gGeometry(); gGeometry = new TGeometry(); > > brick = new TBRIK("invisible_brick","Brick","void",1.,1.,1.); > topNode = new TNode("topNode","TopNode",brick,0,0,0,0); > topNode->SetVisibility(2); > topNode->cd(); > create_wire(topNode); > > } > > topNode->Draw(); > c1->Update(); > > geomApp.Run(); > > return(0); > > } > > void create_wire( TNode *topNode ) { > > TTUBE *wire; > TNode *node; > TRotMatrix *rot; > > topNode->cd(); > > wire = new TTUBE("wire1","Wire","void",0.,1.,10.); > wire->SetLineColor(20); > > rot = new TRotMatrix("rotate","Rotate",95.,10.,90.,100.,5.,10.); > > node = new TNode("node1","Node2",wire,0.,0.,0.,rot); > > } > > Glen > > ********************************************************************* > > Glen R. Salo g.r.salo@ieee.org > Mission Research Corporation (937)429-9261 Ext. 19 > 3975 Research Boulevard (937)429-2625 Fax > Dayton, Ohio 45430-2108 > > *********************************************************************
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:38 MET