P
Peter Koch Larsen
Casper said:How would one go about summing up the memmory custom tree structures
occupies in memmory?
Example:
struct node {
struct node *parent;
unsigned int nChildCount;
string folder; //string class
};
node* pNode = new node;
Using the sizeof(&pNode) returns 4.
So pointers on your architecture are four bytes.
What I am interested in however, is
to know the entire memmory use of an instance of a struct.
Will I have to implement a recursive getSize() method for each node to
include the size of the two struct pointers, the unsigned int and the
string object?
Nope... sizeof(node) returns the number of bytes required by one node. This
is a compile-time value, of course, telling you nothing about the actual
storage requirement of an initialised node.
Thanks in advance,
Casper
/Peter