I encountered "OutOfMemoryException" a few times in .NET applications. There are enough memories. 4GB and 8GB are enough for applications to run smoothly.
After a few incidents, a pattern arises: The resizing of arrays. There are many data structures in .NET related to arrays, or at the lower level, they are implemented on top of an array. For example, the "List" structure, the underlying data structure is an array.
Whenever an item is added to an array, the system needs to check for its capacity and resize if required. A common approach is to double the size. At some point, the system will reject the requested allocation because there is not enough memory space even though the memory is not actually full.
Finding out the root cause is project-dependent.
After a few incidents, a pattern arises: The resizing of arrays. There are many data structures in .NET related to arrays, or at the lower level, they are implemented on top of an array. For example, the "List" structure, the underlying data structure is an array.
Whenever an item is added to an array, the system needs to check for its capacity and resize if required. A common approach is to double the size. At some point, the system will reject the requested allocation because there is not enough memory space even though the memory is not actually full.
Finding out the root cause is project-dependent.