[gecode-users] Memory management bug in 2.2.0?

Christian Schulte cschulte at kth.se
Wed Mar 25 14:59:27 CET 2009


Hi Filip,

yes that was strange stuff and we fixed for 3.0.0... Guido knows more about
it.

Christian

--
Christian Schulte, www.ict.kth.se/~cschulte/


-----Original Message-----
From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Filip Konvicka
Sent: Wednesday, March 25, 2009 2:18 PM
To: users at gecode.org
Subject: [gecode-users] Memory management bug in 2.2.0?

Hi,

I know I'm probably late with this... I am hunting a memory leak in a 
program that uses Gecode 2.2.0. The script (space) constructor 
incrementally adds variables to a var-array (one by one). IMHO, 
VarArray::resize acts strangely:

   VarArray<Var>::resize(Space* home, int m) {
...
     x = static_cast<Var*>(Memory::malloc(sizeof(Var)*newsize));
...
     if (used != n)
       Memory::free(oldx);
     else
       home->reuse(oldx, n);
     n = newsize; used = m;
   }

In my case, "used==n" always holds, so the allocated blocks are 
"deallocated" using Space::reuse(), not Memory::free().

Originally, I was using the default constructor for the array. After I 
saw this I tried to initialize it with (this, 0) in the constructor 
initializer list, but this does not change anything.

It seems to me that VarArray::add and VarArray::resize could never 
actually work... the only way the var-array allocates memory from space 
is in the constructor and update(). Or did I miss something in the docs? 
Is it forbidden to call add and resize?

Thanks,
Filip


_______________________________________________
Gecode users mailing list
users at gecode.org
https://www.gecode.org/mailman/listinfo/gecode-users





More information about the gecode-users mailing list