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
Resource Leak using dynamicarray
Hi Bill,
have you tried to add a FreeAllSeries in the OnClose event ? :
Chart.FreeAllSeries;
have you tried to add a FreeAllSeries in the OnClose event ? :
Chart.FreeAllSeries;
Pep Jorge
http://support.steema.com
http://support.steema.com