[BGL] How can I measure the memory used by a Boost graph ?

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 ?

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
participants (2)
-
Jeremiah Willcock
-
ShNaYkHs ShNaYkHs