[gecode-users] Reporting memory usage

Filip Konvička filip.konvicka at logis.cz
Thu Feb 5 10:19:21 CET 2009


Hi all!

So I'm trying to resurrect this old thread. Shame on me for being so 
late with this.

I've put ideas from several allocators together (including Stéphane's, 
Boost's and other :-)) and the result is in the attachment. There are 
two allocators: Gecode::space_allocator and Gecode::region_allocator. 
These are in fact identical, so we could perhaps make just one template, 
but that would require template templates and I'm not sure how would 
that affect portability. See space_allocator.hpp and region_allocator.hpp.

The allocators can be used with all STL classes, which is demonstrated 
in the example (GecodeAllocTest.cpp). Taking std::set as an example, 
there are two possibilities of how to use the allocators. One is to use 
the allocator just for the nodes, knowing that the destructors of the 
items in the set will be called properly. The other possibility is to 
use the allocator for both the set object and its nodes. This does not 
call the destructor of the set nor the destructors of the items, and 
therefore can improve performance greatly.

To enable the latter, I've added some helper functions as extensions of 
Gecode::Space and Gecode::Region (see extensions.hpp). These could make 
use of variadic templates (or at least Boost Preprocessor), but again, 
that would sacrifice some portability.

My feeling is that this might help with using the STL and Boost data 
structures within the user scripts. It seems a bit clumsy, but just 
during construction/copying. And everyone can make their macros and 
stuff to save some typing if they wish. The only thing that scares me is 
bad usage (e.g. copying a structure along with the foreign allocator 
during cloning), so I think if this is released with Gecode it must 
include some tutorial on how to use it. (One thing that is still missing 
in the code is doxygen documentation.)

BTW, I hereby release all the code under the Gecode license.

All the best,
Filip
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GecodeAllocTest.7z
Type: application/octet-stream
Size: 15006 bytes
Desc: not available
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20090205/e0bc9bf0/attachment.obj>


More information about the gecode-users mailing list