Memory consumption is proportional to number of event

Takeaki Toeda (Takeaki.Toeda@cern.ch)
Tue, 8 Jun 99 19:47:32 +0200


Hello,

I have a data analysis program using TTree.
This program has a serius memory consumption in reading event from Tree.

I deleted member object in event destructor.
But memeory consumption is proprotional to number of event in reading
event
and lastly it reach to 100MB.

What do you know the idea to solve this problem?
Following is a Event.h and Event.cc.

Take-Aki TOEDA

--------------- Event.h --------------------

#ifndef Event_h
#define Event_h
#include <TObject.h>
#include <TObjArray.h>
#include <Device.h>

class Event : public TObject{
public:
Event();
virtual ~Event();
Int_t GetHeader();
Int_t GetHeaderSize();
void ShowHeader();
void ShowDevice();
Int_t GetDeviceType();
Int_t GetEventSize();
Int_t GetEventTypeSize();
Int_t ReadDeviceRecord();
Int_t GetData(int,int);
void ShowDeviceRecord(int);

private:
Short_t Size;
Short_t EvtTypSize;
Device *device;
TObjArray *deviceArray;
ClassDef(Event,1)
};
#endif

---------------- Event.cc --------------

#include <Event.h>
#include <iostream.h>

ClassImp(Event)

Short_t *buffer;
Int_t dbglvl;
Int_t PedestalFlag;

Event::Event(){
deviceArray = new TObjArray(40,0);
}

Event::~Event(){
deviceArray->Delete();
delete deviceArray;
}

Int_t Event::GetHeader(){
Size = *(buffer++);
EvtTypSize = *(buffer++);
ShowHeader();
return 1;
}

void Event::ShowHeader(){
if(dbglvl == 1){
cout << " EventSize = " << Size
<< " EvtTypSiz = " << EvtTypSize
<< endl;
}
}

Int_t Event::GetHeaderSize(){return 2;}
Int_t Event::GetEventSize(){ return (Int_t)Size;}
Int_t Event::GetEventTypeSize(){ return (Int_t)EvtTypSize;}

Int_t Event::ReadDeviceRecord(){
device = new Device();
device->GetHeader();
device->ReadData();
deviceArray->Add(device);
int size = device->GetRecordSize() + 2;
return size;
}

void Event::ShowDeviceRecord(Int_t index){
((Device*)deviceArray->At(index))->ShowData();
}

TObjArray *Event::GetDeviceArray(){
return deviceArray;
}

Int_t Event::GetData(Int_t slot,Int_t ch){
Device *device;
Int_t nSlot;
Int_t data = -999;
Int_t entries = deviceArray->GetEntries();
for(Int_t i=0;i<entries;i++){
device = (Device*)deviceArray->At(i);
nSlot = device->GetSlotNumber();
if(nSlot == slot) data = ((Data*)device->GetData(ch))->GetData();
}
if(data == -999) {
cout << "No module in the slot!" << endl;
}

return data;
}

Int_t Event::GetDeviceType(){
return device->GetDeviceType();
}