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
[email protected]
https://www.gecode.org/mailman/listinfo/gecode-users