In order to debug an out of memory problem I wish to limit the available heap size for mono (swap space not an option). I found a stackoverflow thread about it how can I limit the memory size for .net / mono process - Stack Overflow. Now I am wondering if anyone have been able to set this limit for debugging a Unity game on windows?
running “set MONO_GC_PARAMS max-heap-size=4G” then Unity from the commandline, does not seem to work. Additionally I would prefer to set this limit for the game, not the editor. Is this possible to do?
The size is specified in bytes and must be a power of two. The suffixes `k', `m' and `g' can be used to specify kilo-, mega- and gigabytes, respectively.
While documentation says that suffixes k', m’ and `g’ can be used, it seems that Unity version of Mono runtime just ignores such definitions. But when I specify the size in bytes, like $env:MONO_GC_PARAMS = ‘max-heap-size=4294967296’ in PowerShell, then Unity Editor just refuses to launch (tested with 2022.3.5f1).