Search Unity

Setting MONO_GC_PARAMS max-heap-size for debugging out of memory

Discussion in 'Editor & General Support' started by devtoi, Mar 14, 2017.

  1. devtoi

    devtoi

    Joined:
    Aug 10, 2016
    Posts:
    7
    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 http://stackoverflow.com/questions/15860481/how-can-i-limit-the-memory-size-for-net-mono-process. 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?
     
  2. korneidontsov

    korneidontsov

    Joined:
    Mar 13, 2020
    Posts:
    1
    https://github.com/mono/mono/blob/89f1d3cc22fd3b0848ecedbd6215b0bdfeea9477/man/mono.1#L1308
    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).