title: Memory Consumption of Collection Types
body: <p>I am trying to make a small app that uses a multiple hierarchy of type List within a List for some 20-30 levels. I tried with:</p>
  
  <p><code>System.Collections.ComponentModel.ObservableCollection</code>, but at run time, I got an <code>OutOfMemoryException</code> error. Then, I tried with List, and this time I did not get such an error.</p>
  
  <p>What type of collection consumes the least amount of space? Or, what would be a good way to achieve this type of hierarchy? I just need a collection; I don't need change notifications, etc. I am using .NET 4 with VB, Linq, and WPF. I achieved the code looping process with <code>Parallel.ForEach</code> threading. </p>
  
  <p>Edit:
  The Program is for string the file system data into Sql CE DB and retrieving it back.  Hence, the hierarchy can be of 20-30 levels also.</p>
  
  <p>Edit: There would be about 80000 Queries with linq for getting the hierarchy. The Type of data I am using is as follows:</p>
  
  <pre><code>Public Structure FileRecord
          Property ID As String
          Property Namee As String
          Property Size As String
          Property IsFolder As Boolean
          Property DateModified As Date
          Property FullPath As String
          Property Disk As String
          Property ParentID As String
          Property Items As List(Of FileRecord)
  End Structure
  </code></pre>