Boost logo

Boost :

Subject: Re: [boost] [BGL] How can I measure the memory used by a Boost graph ?
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2012-06-29 16:29:39


On Fri, 22 Jun 2012, ShNaYkHs ShNaYkHs wrote:

> Hi,
> I have a graph defined as follow:
>
> struct NodeData{ /*...*/ };
> struct EdgeData{ /*...*/ };
> typedef adjacency_list<setS, setS, undirectedS, NodeData, EdgeData> MyGraph;
> MyGraph G;
>
> This graph is updated iteratively (by adding/deleting some edges/vertices).
> At each iteration, I want to evaluate the memory space occupied by this
> graph G. How can I do that ?

There really isn't a good way to do that, especially given that std::set
and std::map will use various internal data structures whose sizes are
implementation-specific. What are you planning to use this information
for? Would something simple and very approximate like (num_vertices(G) *
sizeof(NodeData) + num_edges(G) * sizeof(EdgeData)) be close enough?

-- Jeremiah Willcock


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk