Re: De-alloc Memory

From: Jarek Grebieszkow (Jarek.Grebieszkow@cern.ch)
Date: Sat Dec 05 1998 - 01:42:22 MET


Hi Jeff,

and what about TClonesArray ? Consider such example without new/delete
overhead. You can use TClonesArray as a buffer for your histograms.

{
  TClonesArray  a("TH1F", 1000);
  Char_t buf[10];
   
  while(1) {
    // Create some histograms  

     for(Int_t i=0; i<10000; i++)
      {
        sprintf(buf,"H%d", i);
        new(a[i]) TH1F(buf, buf, 10, 0., 1.);
      }

    //Play whit histos
      
    //Delete them
    a.Delete();
  }
}

						Regards,
						  Jarek


On Fri, 4 Dec 1998, Jeff Patterson wrote:

> Hey Rooters,
> 
> 	I am writing a macro that needs to create ALOT of TH1 and TH2.
> All of these histograms quickly eat up memory.  I want to create a handful
> of them, get the numbers from them, deconstruct them (free up their
> memory), then construc the next set of them.  I deconstruct them, but the
> memory does not seem to be freed up after words.  I have tried many
> things.  I use pointer to them.
> 
> i.e.
> 		TH1F *one[10];
> 		TH2F *two[10];
> 	for(i=0, i<100, ++i)
> 	{
> 		one = new TH1F( STUFF DEPENDIING ON i);
> 		two = new TH2F(MORE STUFF DEPENDING on i);
> 			.
> 			.
> 			.
> 
> 		//Store the numbers of counts in arrays
> 		   //Now it's time to get rid of them !!!
> 		  
> 		delete[] one;
> 		delete[] two;
> 	}
> 
> If I run this loop, all my memory is quickly gone after a couple of
> itteration.  The delete[] stuff does not seem to be working.  I have also
> tried free(one[0]); free(one[1]); etc.....
> 	And calling the ~TH1F and ~TH2F desonctructos, and nothing seems
> to work.  Where am I going wrong ?
> 
> 
> 				Thanks in advance,
> 					Jeff Patterson
> 
> 



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:40 MET