[gecode-users] Memory Leak with NaryUnion/Region(?)

Christian Schulte cschulte at kth.se
Tue Mar 27 10:25:40 CEST 2012


Yes, that would be one way. And you would have to recompile. The downside
would be that you allocate some more memory.

But there is a simpler fix (at least for your example): always create a
fresh region, it is cheap. So in your example do:
       for(int j=0;j<8;j++){
           Region region(home);
           Iter::Ranges::Empty e;
           Iter::Ranges::NaryUnion unio(region,e);
       }

Can I ask what you are trying to do? I am just curious.

Best
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 Jean-Noël Monette
Sent: Tuesday, March 27, 2012 10:14 AM
To: users at gecode.org
Subject: Re: [gecode-users] Memory Leak with NaryUnion/Region(?)

Hi,

Thanks for your answer.

In the mean time, if I want to avoid this leak, is it ok to change the
constant "region_area_size" in "memory_config.hpp" to some larger value? 
What would be downside of doing this? And if I do so, do I need to recompile
the whole gecode Library, or is it sufficient to recompile my own model?

Thank you,

Jean-Noël Monette

On 03/26/2012 04:07 PM, Christian Schulte wrote:
> Hmm, thanks for the report. I might not fix that soon as the whole 
> implementation for Region might change.
>
> Thanks a lot!
> 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 Jean-Noël Monette
> Sent: Monday, March 26, 2012 1:53 PM
> To: users at gecode.org
> Subject: [gecode-users] Memory Leak with NaryUnion/Region(?)
>
> Hello,
>
> Sorry for bothering you again with the same class, namely NaryUnion...
> When running the next piece of code, within valgrind (memcheck), I get 
> a report for a memory leak...
>
> #include "gecode/driver.hh"
> #include "gecode/iter.hh"
> using namespace Gecode;
> class MySpace:public Space {
>       public:
>           virtual Space* copy(bool share){return this;} }; int 
> main(int argc,
> char* argv[]){
>       MySpace home;
>       Region region(home);
>       for(int j=0;j<8;j++){
>           Iter::Ranges::Empty e;
>           Iter::Ranges::NaryUnion unio(region,e);
>       }
> }
>
>
> The report is as follows:
>
>
> ==9213== HEAP SUMMARY:
> ==9213==     in use at exit: 40 bytes in 1 blocks
> ==9213==   total heap usage: 319 allocs, 318 frees, 94,497 bytes allocated
> ==9213==
> ==9213== 40 bytes in 1 blocks are definitely lost in loss record 1 of 1
> ==9213==    at 0x4C28FAC: malloc (vg_replace_malloc.c:236)
> ==9213==    by 0x6582629: Gecode::Region::heap_alloc(unsigned long)
> (heap.hpp:324)
> ==9213==    by 0x40474F: main (region.hpp:306)
> ==9213==
> ==9213== LEAK SUMMARY:
> ==9213==    definitely lost: 40 bytes in 1 blocks
> ==9213==    indirectly lost: 0 bytes in 0 blocks
> ==9213==      possibly lost: 0 bytes in 0 blocks
> ==9213==    still reachable: 0 bytes in 0 blocks
> ==9213==         suppressed: 0 bytes in 0 blocks
>
>
> The leak does not appear when looping only for 7 iterations instead of 8.
> This seems quite normal as the memory is allocated on the heap only 
> when the region space is exhausted (according to MPG). I am using 
> Gecode 3.7.1, gcc 4.5.2, Linux-Ubuntu 11.04 over a 64 bits 
> architecture.  Is it some kind of bug, or should I stop using NaryUnion
once and for all?
>
> Thank you again for your help,
>
> Jean-Noël monette
>
>
> _______________________________________________
> Gecode users mailing list
> users at gecode.org
> https://www.gecode.org/mailman/listinfo/gecode-users
>
>

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




More information about the users mailing list