Resource Leak using dynamicarray

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
BE
Newbie
Newbie
Posts: 41
Joined: Tue Nov 16, 2004 5:00 am

Resource Leak using dynamicarray

Post by BE » Tue Jan 15, 2008 3:38 pm

Hi,

I have a project that uses DynamicArray to pass array to Chartseries in BCB2007. with CodeGard turned on, I've been getting resource Leak msgs. So I build the following sample case. Sure enough. There's a resource leak msg.


#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "Chart.hpp"
#include "Series.hpp"
#include "TeEngine.hpp"
#include "TeeProcs.hpp"
#include <ExtCtrls.hpp>
#include <Buttons.hpp>
//---------------------------------------------------------------------------

typedef DynamicArray < double > TDARRAY;


class TForm1 : public TForm
{
__published: // IDE-managed Components
TChart *Chart1;
TPanel *Panel1;
TBitBtn *BitBtn1;
TFastLineSeries *Series1;
void __fastcall BitBtn1Click(TObject *Sender);
private: // User declarations

TDARRAY DataX;
TDARRAY DataY;

public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif


// .cpp code

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "Chart"
#pragma link "Series"
#pragma link "TeEngine"
#pragma link "TeeProcs"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
DataX.Length = 101;
DataY.Length = 101;

for(int i = 0; i < DataX.Length; i++)
{
DataX = i * 0.5;
DataY = i * i * 0.5;
}

Series1->XValues->Value = DataX;
Series1->XValues->Count = DataX.Length;
Series1->XValues->Modified = 1;
Series1->YValues->Value = DataY;
Series1->YValues->Count = DataY.Length;
Series1->YValues->Modified = 1;

}
//---------------------------------------------------------------------------

When I run this program with CodeGard on, I'll get Resource Leak after closing the program.

Where is the leak coming from?

I'm using TChart Pro v7.12 win32.

CodeGear™ C++Builder® 2007 Pro Version 11.0.2902.10471

Thanks

-Bill

Pep
Site Admin
Site Admin
Posts: 3274
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Jan 31, 2008 7:30 am

Hi Bill,

have you tried to add a FreeAllSeries in the OnClose event ? :

Chart.FreeAllSeries;

BE
Newbie
Newbie
Posts: 41
Joined: Tue Nov 16, 2004 5:00 am

Post by BE » Thu Jan 31, 2008 2:10 pm

I'll give that a try.

Thanks

Post Reply