Change the garbage collector used by Unity ?

Hello,

I would like to know if it was possible to change the implementation of the garbage collection used in unity.

For example, in Java, there are some non blocking garbage collection. Is there some equivalent and usable for unity in c# world ?

Thanks.

I don’t think so… It’s on the roadmap of things to be upgraded (generational GC), but nothing that I’m aware of beyond that.

Too bad :frowning:
thank you for answering

Ya, I think everyone will be happy when the new GC is implemented :slight_smile: But we survive until then… :slight_smile:

Unity 2019.1 comes with an Incremental Garbage Collection, that smears-out any GC spikes over many frames:
https://blogs.unity3d.com/2018/11/26/feature-preview-incremental-garbage-collection/

It’s in Alpha now, but if someone (like me) really needs it before his/her deadline, there is 1 issue you might face when building for Android:

  • keystore passwords not being recognised as you type them, or perhaps, only in a Development Build.

To solve this for now, I did the following:

  1. used cmd and java’s “keytool” to generate an RSA keystore (google or youtube how to do it)
  2. Selected the generated keystore from ProjectSettings/Player, but didn’t enter passwords, nor selected the Alias.
  3. Placed the following code in Editor, and ran it:
using UnityEngine;
using UnityEditor;
public class BuildSettings_Set_KeystoreVals : MonoBehaviour
{
    const string androidKeystorePass = "YourPassword";
    const string androidKeyaliasName = "YourKeystoreKeyAlias";
    const string androidKeyaliasPass = "YourAliasPassword";
 
    [MenuItem("Build/Set_KeystoreVals")]
    static void Set_KeystoreVals(){
        PlayerSettings.Android.keystorePass = androidKeystorePass;
        PlayerSettings.Android.keyaliasName = androidKeyaliasName;
        PlayerSettings.Android.keyaliasPass = androidKeyaliasPass;
    }
}
  1. Built the application in Mono

interesting…

though honestly, with how we’ve written our code up to this point, GC hasn’t been an issue for us

I still look forward to it. I like the prospect of possibly other GC engines down the line.