Problem of memory leakage

Hi,

I am developing a stand alone application using ROOT on Windows XP. Particularly, from the main frame I open a dialog frame having TRootEmbeddedCanvas and draw some data.
All work. But, I found that each call of the dialog frame and drawing increase the using memory on 3 MBytes and when it closed the using memory is decreassed on 2 MBytes only. Thus, 1 Mbytes is leaked on each call. What may be wrong?
The Main frame has a slot, which get a signal from the dialog frame and close it. I checked two variants for the drawing. (1) Dialog frame returns the reference on TCanvas and another class draw on this canvas. (2) Dialog frame gets a references on some TH1D objects and draws them. Botn variants work but memory leakage remains.

Andrei

//----------------------------------------------------------------------
void RM_MainFrame::CloseShowP()
{
pShowP->Disconnect();
delete pShowP;
pShowP = NULL;
}

//----------------------------------------------------------------------
void RM_MainFrame::ShowProj(int direct)
{
if(!pShowP)
{
pShowP = new RM_ShowP(gClient->GetRoot(), fMF->GetMainFrame(), direct);
pShowP->Connect(“CloseShowP()”,“RM_MainFrame”, this, “CloseShowP()” );
}
pArea->GetProj(direct)->DrawRes(pShowP->GetCanvas());
}

ClassImpQ(RM_ShowP)
//----------------------------------------------------------------------
RM_ShowP::RM_ShowP(const TGWindow *p
,const TGWindow *pMain
,int _direct)
:direct(_direct)
{
fFrame = new TGTransientFrame(p,pMain,900,400,kVerticalFrame | kFixedWidth);
fFrame->Connect(“CloseWindow()”,“RM_ShowP”,this,“ExecClose()”);
fFrame->DontCallClose();
fFrame->SetCleanup(kDeepCleanup);

SetFrames();
if(direct == 0)
    fFrame->SetWindowName("FITTING RESULT OF X-PROJECTION");
else
    fFrame->SetWindowName("FITTING RESULT OF Y-PROJECTION");

fFrame->MapSubwindows();
fFrame->Resize();
fFrame->MapWindow();

}

//----------------------------------------------------------------------
RM_ShowP::~RM_ShowP()
{
fFrame->DeleteWindow();
}

//----------------------------------------------------------------------
void RM_ShowP::ExecClose()
{
TTimer::SingleShot(150,“RM_ShowP”,this,“CloseShowP()”);
}

//----------------------------------------------------------------------
void RM_ShowP::CloseShowP()
{
Emit(“CloseShowP()”);
}

//----------------------------------------------------------------------
void RM_ShowP::SetFrames()
{
fHU = new TGHorizontalFrame(fFrame,900,400,kChildFrame | kFixedWidth);
fHD = new TGHorizontalFrame(fFrame,120,30,kChildFrame | kFixedWidth);
fFrame->AddFrame(fHU,new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX | kLHintsExpandY));
fFrame->AddFrame(fHD,new TGLayoutHints(kLHintsRight | kLHintsBottom));

fTBok = new TGTextButton(fHD,"Ok");
fTBok->Connect("Clicked()", "RM_ShowP", this, "ExecOk()");
fTBsave = new TGTextButton(fHD,"Save");
fTBsave->Connect("Clicked()","RM_ShowP", this, "ExecSave()");
fHD->AddFrame(fTBok, new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandX ,2,0,2,2));
fHD->AddFrame(fTBsave, new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandX ,2,0,2,2));

fECanvas = new TRootEmbeddedCanvas("ECanvasM", fHU, 300,300);
fHU->AddFrame(fECanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,5,5,5,5));
pCanvas = fECanvas->GetCanvas();
pCanvas->Divide(1,2);

}

Hi Andrei,
Please try the following changes:

  • remove in RM_ShowP constructor the line: fFrame->SetCleanup(kDeepCleanup);
  • change the dtor following way:RM_ShowP::~RM_ShowP() { fHU->Cleanup(); fHd->Cleanup(); fFrame->Cleanup(); fFrame->DeleteWindow(); } Please let me know if the memory leak disappeared after the proposed changes.
    Cheers, Ilka

Hi Ilka

It does not help.

  1. Also, I used root 5.04 and changed it on root 5.06 without success.
  2. I excuded drawing on canvas without success.

Sincerely yours,
Andrei

Hi Andrei,

Please provide a running example for testing with as simple as possible application window (fMF->GetMainFrame()).

Thank you, Ilka

Hi Ilka

I attached working code using my dialog frame.

Andrei
GSProjectTest.rar (383 KB)