What are trying to achieve? creating/deleting windows is not a good idea, since the window allocated by X11 itself will not be freed until Root terminates.
Before starting to investigate a way to delete everything in your code, including the resources allocated by X11, it would be good to understand what you are trying to do, there is probably a better way to do it…
One general (C++) comment: You must always initialize your pointers to 0, especially if you test their validity like:
if (MyTableFrame) {
...
You can do it in the constructor of your class, for example:
if (MyTableFrame) {
MyCompositeFrame->RemoveFrame(MyTableFrame);
delete MyTableFrame;
}
by MyCompositeFrame->Cleanup();
This code works for me on Linux(slc4) and Windows with svn trunk (didn’t try with other versions).
And about the memory, I don’t see real issues, the memory increase a bit when you create the frames, but then it stabilizes (i.e. creating and deleting frames doesn’t continuously increase the memory)
Thank you for the answer.
But no, i’m sure there is a memory leak.
I have also tested ROOT 5.27/04, and nothing changed:
memory usage of xorg increases continuosly.
(opensuse 11.3 and SL5.4, 64 bit)
Can anyone confirm the memory leak?
I think that the TCanvas created by TRootEmbeddedCanvas has to be closed in the destructor of the component.
[quote=“yawn”]Your solution is interesting, and works in the example.
But i’m not able to adapt to my real code.[/quote]But I have the same behavior with your code than with the example…
Anyway, can you test the following modification on your system?
Just add:
if (fCanvas->GetCanvasID() >=0 ) {
gVirtualX->SelectWindow(fCanvas->GetCanvasID());
gVirtualX->CloseWindow();
}
In the TRootEmbeddedCanvas destructor (in $ROOTSYS/gui/gui/src/TRootEmbeddedCanvas.cxx), as show below:
if (!MustCleanup()) {
if (fCanvas->GetCanvasID() >=0 ) {
gVirtualX->SelectWindow(fCanvas->GetCanvasID());
gVirtualX->CloseWindow();
}
delete fCanvas;
delete fCanvasContainer;
}
delete [] fDNDTypeList;
}
[/code]
And let me know if it changes anything, please. And if you cannot make the change and/or build Root from source, then I’ll make more tests and I’ll let you know.