Possible Duplicate:
How to refer to children in a tree with millions of nodes
I'm trying to implement a tree which will hold millions of nodes, which in turn can have an unspecified number of children nodes.
To achieve this (since each node can have more than one child node), I'm storing a node's children within a Dictionary data structure. As a result of this, when each object node is created (out of millions), I've got a node object which contains a character value stored in the respective node, aswell as a separate Dictionary structure which holds a reference to the children nodes.
My tree works for a few thousand nodes, however when it reaches millions of nodes, an out of memory exception occurs. Is this due to the fact that each one of the millions of nodes running in memory also has its own Dictionary? i.e. I've got millions of objects running?
I need to have these objects running in memory, and cannot use files or databases. Could anyone suggest a solution?
Do you know the number of your childs when inializing or not?
The children should be stored in Lists, not dictionaries. – weismat Mar 12 '12 at 15:43