Board index » cppbuilder » Cann't free the memory of my code, but I deleted all the calss, why?

Cann't free the memory of my code, but I deleted all the calss, why?


2003-11-08 06:30:57 PM
cppbuilder98
I write a class to generate some pic, use the TChart component,
but when I use the class, it use a lot of memory and do not free
when I delete the class, why?
these are the main function of my class
--------------------------------------------------------
bool BornPicture::BornAnother(TForm* myForm)
{
//the 'czScoreEngine' and 'czTool' are other classes
//1
TStringList* lsZScore = new TStringList;
AnsiString sTemp;
czScoreEngine myScore(qName, qScore, qUserInput, qModalSelect);
myScore.czGetPara();
sTemp = myScore.czConvertScore(qScore);
sTemp = myScore.czCaclFactor(sTemp);
sTemp = myScore.czModelNormalZ(sTemp);
lsZScore->Text = czTool.czConvertSpaceToReturn(sTemp);
//2
TChart* myChart = new TChart(myForm);
TLineSeries* myLine = new TLineSeries(myForm);
TBarSeries* myBar = new TBarSeries(myForm);
TJPEGImage* myImage = new TJPEGImage();
TImage* myTempImage = new TImage(myForm);
myChart->AddSeries(myLine);
myChart->AddSeries(myBar);
//3
myChart->Parent = myForm;
myChart->Title->Text->Clear();
myChart->Title->Text->Add("人群分布");
myChart->BackColor = clWhite;
myChart->BevelInner = Controls::bvNone;
myChart->BevelWidth = Controls::bvNone;
myChart->Color = clWhite;
myChart->LeftWall->Color = clSilver;
myChart->BottomWall->Color = clSilver;
myChart->LeftAxis->Title->Caption = "";
myChart->BottomAxis->Title->Caption = "标准分";
myChart->Width = 300;
myChart->Height = 300 * 3/4;
myChart->AutoSize = false;
myChart->Visible = false;
myChart->AxisVisible = false;
myChart->View3D = false;
myChart->LeftAxis->Maximum = 0.5;
myChart->LeftAxis->Minimum = 0;
myChart->Legend->Visible = false;
myChart->Visible = true;
myLine->Active = false;
myLine->Stairs = false;
myLine->Marks->Visible = false;
myLine->Marks->Transparent = false;
myLine->ShowInLegend = false;
myLine->LineHeight = 0.1;
myLine->LinePen->Width = 1;
myLine->Marks->Style = smsLabelValue;
myBar->Active = false;
myBar->BarStyle = bsArrow;
myBar->Marks->Transparent = false;
myBar->Marks->Visible = true;
myBar->BarWidthPercent = 20;
myBar->Active = true;
myLine->Active = true;
myTempImage->Parent = myForm;
myTempImage->Width = myChart->Width;
myTempImage->Height = myChart->Height;
myTempImage->Visible = false;
//4
float fTemp = -3.0;
float fTempY;
while (fTemp<3.0)
{
myLine->AddXY(fTemp, (pow(2.7183 , -(fTemp*fTemp)/2))/(sqrt(2*3.1415)) , "", clRed);
fTemp+=0.01;
}
//5
for (int i=0; i<lsZScore->Count ; i++)
{
fTemp = lsZScore->Strings[i].ToDouble();
fTempY = (pow(2.7183 , -(fTemp*fTemp)/2))/(sqrt(2*3.1415));
myBar->Clear();
myBar->AddXY(fTemp, fTempY , "Your Position: " + FormatFloat("0.00", czTool.czNormalPercent(fTemp)*100) + "%", clTeeColor );
myChart->Draw(myTempImage->Canvas, myChart->ClientRect);
myImage->Assign(myTempImage->Picture->Bitmap);
myImage->SaveToFile(ExtractFilePath(Application->ExeName) + "\\temp\\Result"+IntToStr(i)+".jpg");
}
delete myLine;
delete myBar;
delete myChart;
delete myImage;
delete myTempImage;
delete lsZScore;
return true;
}
 
 

Re:Cann't free the memory of my code, but I deleted all the calss, why?

"TomCai" < XXXX@XXXXX.COM >writes:
Quote
I write a class to generate some pic, use the TChart component,
but when I use the class, it use a lot of memory and do not free
when I delete the class, why?
Hard to tell. You provide too much code, and, at the same time, too little.
Please post a minimal (<50 lines), but *complete* (compilable and runnable)
program. You can shorten BornPicture::BornAnother() a lot for this.
It would also be interesting to know how you determine that the memory is
not freed.