title: Memory exception in C#
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/9649722/how-to-refer-to-children-in-a-tree-with-millions-of-nodes">How to refer to children in a tree with millions of nodes</a>  </p>
  </blockquote>
  
  
  
  <p>I'm trying to implement a tree which will hold millions of nodes, which in turn can have an unspecified number of children nodes.</p>
  
  <p>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.</p>
  
  <p>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?</p>
  
  <p>I need to have these objects running in memory, and cannot use files or databases. Could anyone suggest a solution?</p>