? > Hi, > It's my understanding that when a dynamically allocated TCanvas is > closed, it's memory is freed. Is this correct? Also, is it true that > the memory of objects drawn into a TCanvas are deleted by the TCanvas's > dtor? (I'm assuming that the objects have not been added to a global > directory.) Not it is not TCanvas doesn't delete any object one created with "new" on its own. If you want TCanvas to delete the object you created you have to MARK your object with TObject::SetBit(kCanDelete); In your case gr = new TGraph(100, x, y); gr->SetBit(kCanDelete); gr->Draw("PA"); Hope this helps. Valery > As it stands, does code like the following leak memory? Yes it does ! TGraph will be not deleted. > void displayGraph() > { > Float_t x[100]; > Float_t y[100]; > TGraph *gr; > TCanvas *c; > > for (Int_t i = 0; i < 100; i++) { > x[i] = (Float_t) i; > y[i] = 5.9 * x[i]; > } > > c = new TCanvas("c", "A canvas", 0, 0, 400, 400); > gr = new TGraph(100, x, y); > gr->Draw("PA"); > c->Modified(); > c->Update(); > } >
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:37 MET