[Graph] How to free memory allocated when constructing a graph?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Graph] How to free memory allocated when constructing a graph?

Olivier Delalleau
I am constructing a graph exactly the same way as in the spanning tree
example here:
    http://www.boost.org/libs/graph/example/prim-example.cpp
i.e. using a constructor of the kind
    Graph g(edges, edges + sizeof(edges) / sizeof(E), weights, num_nodes);
where Graph is some kind of adjacency_list.
In my application, edges is rather big (on the order of 1e7 elements).

Problem: when this constructor is called, it allocates a huge amount of
memory (I see this when I do a 'top' to monitor the memory usage while
in gdb). And this memory is not freed when the graph is deleted (when it
gets out of the scope, or, if I use a pointer instead, when I delete it
explicitely).
Is there a way to recover this memory? Any hint on how to make it use
less memory?

Thank you,

Olivier
_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [Graph] How to free memory allocated when constructing a graph?

Doug Gregor-2

On Mar 15, 2006, at 9:25 PM, Olivier Delalleau wrote:

> I am constructing a graph exactly the same way as in the spanning tree
> example here:
>     http://www.boost.org/libs/graph/example/prim-example.cpp
> i.e. using a constructor of the kind
>     Graph g(edges, edges + sizeof(edges) / sizeof(E), weights,  
> num_nodes);
> where Graph is some kind of adjacency_list.
> In my application, edges is rather big (on the order of 1e7 elements).
>
> Problem: when this constructor is called, it allocates a huge  
> amount of
> memory (I see this when I do a 'top' to monitor the memory usage while
> in gdb). And this memory is not freed when the graph is deleted  
> (when it
> gets out of the scope, or, if I use a pointer instead, when I  
> delete it
> explicitely).
> Is there a way to recover this memory? Any hint on how to make it use
> less memory?

If it's true that we're not deallocating memory properly in the graph  
data structure, it's a critical bug that we absolutely must fix.  
"top", however, isn't useful for determining if there is a memory leak.

        Doug
_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users