Re: dynamical versus non dynamical for TH1F

From: Marc Escalier <escalier_at_lal.in2p3.fr>
Date: Sun, 24 Jan 2010 13:10:40 +0100


thanks for all the fruiftul comments

> trying to call it off-scope (second loop). Note that you don't delete
> 'person', you delete 'marc' which is the object. Try this

you're right, i made a mistake (i didn't compile this commented line, this is why i made this mistake)

> Can you send the code you are using ?

yes, i compile the code :
(i do g++ mycode.C )

the code is :

#include <iostream>

int main()
{

   class person
   {
   public :
     int age;
   };

   for (int j=0;j<1000;j++) {

     for (int i=0;i<100000;i++) {
       class person *marc=new person();
       marc->age=33;
       delete marc;
       // std::cout << "age de marc=" << marc->age << std::endl;
     }

   }
}

i had a look at valgrind as you suggest for the dynamical allocation and the standard one.

So thanks to your nice comments, i'm happy now to do dynamical allocation for the histograms

regards Received on Sun Jan 24 2010 - 13:10:46 CET

This archive was generated by hypermail 2.2.0 : Sun Jan 24 2010 - 23:50:01 CET