[gecode-users] Gecode memory question

Gustavo Gutierrez ggutierrez at atlas.puj.edu.co
Fri Dec 4 20:00:05 CET 2009


Dear all,

I am trying to implement something which at a first sight could look weird
and have a memory problem, I will try to be as concise as possible while
giving enough details to have some help from you; if you need to know more,
I don't have any problem to explain my situation in a deeper way.

I have some data structures which are external to propagators but that I
need to share among computation spaces. Still, I would like to have this
data structures allocated in some way by gecode itself and not from using
new (malloc). Let's have a look at the following example of a main program
creating some instances of Space:


 opt.parse(argc,argv);
 Space *sp = new Simple(opt);
 sp->status();
 Space *csp = sp->clone(true);
 csp->status();
 //delete sp;
 Space *csp2 = csp->clone(true);


Just assume that there are no propagators posted during the construction of
Simple, just a branching. Now, If I am right, by sending true to clone will
cause the data structures (variables, etc) to be shared. Then csp will share
data structures with sp. Now, I am considering to clone (and share again the
data structures) csp into csp2. If at some point, I decided to delete sp I
will get a memory problem, this is, there are data structures inside csp2
that are supposed to *point* to something that where in sp but now is
deallocated.

I am using the space allocator to allocate the data structures, so I think
that a space is deallocated by removing its complete heap from memory. If I
understand correctly, there is a one to one relation between a space and a
space heap. In my case, I would like to allocate the data structures
somewhere else in such a way that those are no removed when spaces are
deallocated. Is it possible to do that in gecode?, is there some "general
heap" from which I can allocate memory from?, if yes, is there an allocator
to allocate memory from this part?.

I would like the memory to be allocated by gecode because in that way (I
think) it will be reported as part of the statistics when running a search
engine. Also, the data structures I am using use reference counting for the
memory management but are not thread safe so I would like to know how this
would interact with parallel search engines. I don't want to cause any heap
segmentation (I am not sure how much sensible is gecode to memory alignment
in its heap and things like that) that severely affects gecode performance.


Any comment is more than welcome and thanks in advance.

Gustavo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20091204/9a750ff8/attachment.htm>


More information about the users mailing list