[gecode-users] Memory trouble when implementing a brancher

Christian Schulte cschulte at kth.se
Mon Dec 13 11:49:00 CET 2010


Hi,

 

By default, the dispose() member function of a brancher is not called when
its space is deleted. The brancher must register itself for the dispose()
member function to be called. Please check Section 21.9 in MPG on how to do
that.

 

I hope that helps.

 

Best

Christian

 

--

Christian Schulte, web.ict.kth.se/~cschulte/

 

 

From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Anders Helmar
Sent: Sunday, December 12, 2010 12:19 PM
To: users at gecode.org
Subject: [gecode-users] Memory trouble when implementing a brancher

 

Hi..

 

I'm facing a problem with memory leaks when implementing my own brancher in
Gecode 3.4.0, using the GCC compiler on an ubuntu platform. 

 

My problem is that I want to save both a position for a variable but also a
list of values to branch on. This list is created as a vector<int> in the
implemented brancher together with the position as

 

mutable vector<int> alternatives;

mutable int v;

 

I have a choice object as well with a vector and an integer to be stored in
the choice.

 

In the status() function I fill in the alternatives with the push_back()
function, and it is here I get my leaks when running with valgrind.

 

When I have created the choice in the Choice() function of the brancher I
remember to clear the vector of alternatives (Since choice takes a local
copy for the choice object).

 

I suppose that when deleting my choice pointer in the search engine, I also
delete the elements in the list of alternatives in the choice object? I
suspect that the problem lies within the garbage collector of the choice.

 

Hope you can help!

 

Cheers, 

Anders

 

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20101213/92e3e24f/attachment.htm>


More information about the users mailing list