|
Boost Users : |
From: FBSL (fbsl_at_[hidden])
Date: 2005-04-24 10:50:46
Thanks for answering.
Stefan Strasser wrote:
> you're right, the BGL uses the default new operator to allocate memory
> which then isn't collected of course.
> so this makes it effectively impossible to use BGL with boehm GC.
> is there a boost guideline to allocate memory only through allocators
> which is violated here?
> (the "new" which is causing the leak(or one of your leaks?) in your
> code is at line 278 of graph/detail/adjacency_list.hpp in version 1.32)
As a matter of facts, by modifying the snippet code and commenting out
the add_edge() instruction, the binary no longer leaks, so the guilty
"new" is certainly the one you point (which allocate for an edge
property). I tried to replace it by "new (UseGC)" in order to check if
edge properties become collectable, but unfortunately this does not
work, binary still leaks...
Snippet code is again provided.
-- #include <boost/graph/adjacency_list.hpp> #include <gc/gc_allocator.h> #include <gc/gc_cpp.h> #include <iostream> #include <vector> #include <list> using namespace std; using namespace boost; namespace boost { struct collected_vecS {}; struct collected_listS {}; template <class ValueType> struct container_gen<collected_vecS, ValueType> { typedef vector<ValueType,gc_allocator<ValueType> > type; }; template <class ValueType> struct container_gen<collected_listS, ValueType> { typedef list<ValueType,gc_allocator<ValueType> > type; }; template <> struct parallel_edge_traits<collected_vecS> { typedef allow_parallel_edge_tag type; }; template <> struct parallel_edge_traits<collected_listS> { typedef allow_parallel_edge_tag type; }; namespace detail { template <> struct is_random_access<collected_vecS> { enum { value = true }; typedef true_type type; }; } } typedef adjacency_list<collected_vecS, collected_vecS, directedS, no_property, no_property, no_property, collected_listS> graph; int main() { while(true){ graph * g=new (UseGC) graph; for(unsigned int i=0; i<100; ++i){ add_vertex(*g); } for(unsigned int i=0; i<100; ++i){ for(unsigned int j=0; j<100; ++j){ // if uncommented, leaks // add_edge(i,j,*g); } } } }
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net