Out of Memory Exception
When you're working with very large models, you may encounter a System.OutOfMemoryException
while building your model.
This happens, when the allocated heap memory of your .net application exceeds 2GB, or if there is not enough consecutive memory available to allocate an array/dictionary/list/etc.
In order to prevent this, you need to explicitly allow the heap size to grow larger. This can be done by modifying your App.config
file. Add the following parameter to it:
<configuration>
<runtime>
<gcAllowVeryLargeObjects enabled="true" />
</runtime>
</configuration>
For more information, you can refer to the following resources:
- https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/gcallowverylargeobjects-element
- https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/clr-configuration-knobs.md#garbage-collector-configuration-knobs
- Alternative configuration method when running a .net standard application.