How to detect RAM memory of an Android device

Hello! I want to automatically set the graphic level and resolutions according to the Android device.
I think I need to detect how much memory each device has and set the appropriate graphics/resolution.

I tried to use :

    private void Start()
    {
        StartCoroutine(fixres());
    }

    IEnumerator fixres()
    {
        yield return new WaitForSeconds(0.5f);
        if (SystemInfo.systemMemorySize < 2048)
        {
            restext.text = "" + SystemInfo.systemMemorySize + "mb, graphic level 1";
            QualitySettings.shadows = ShadowQuality.Disable;
            QualitySettings.masterTextureLimit = 2;
            QualitySettings.SetQualityLevel(0, true);
            QualitySettings.particleRaycastBudget = 32;
            Screen.SetResolution(800, 480, true);
        }
        else if (SystemInfo.systemMemorySize > 4000)
        {
            restext.text = "" + SystemInfo.systemMemorySize + "mb, graphic level 2";
            QualitySettings.SetQualityLevel(2, true);
            QualitySettings.masterTextureLimit = 0;
            QualitySettings.particleRaycastBudget = 64;
            PlayerPrefs.SetInt("resolutiontype", 1);
            PlayerPrefs.SetInt("graphictype", 1);
            Screen.SetResolution(1280, 720, true);
        }     
    }

On PC I see my memory
8454707--1121972--upload_2022-9-21_11-32-17.png

When I play the game on my Android device, I cannot see its memory… The coroutine isn’t running or something… Why?

SystemInfo.systemMemorySize works for Android devices or just for PC?

I also made a script to test each graphics level on my device :

public void Low()
    {
        QualitySettings.shadows = ShadowQuality.Disable;
        QualitySettings.masterTextureLimit = 2;
        QualitySettings.SetQualityLevel(0, true);
        QualitySettings.particleRaycastBudget = 32;
        Screen.SetResolution(800, 480, true);
    }

    public void Medium()
    {
        QualitySettings.shadows = ShadowQuality.Disable;
        QualitySettings.masterTextureLimit = 1;
        QualitySettings.particleRaycastBudget = 32;
        QualitySettings.SetQualityLevel(1, true);
        Screen.SetResolution(960, 540, true);
    }

    public void High()
    {
        QualitySettings.SetQualityLevel(2, true);
        QualitySettings.masterTextureLimit = 0;
        QualitySettings.particleRaycastBudget = 64;
        PlayerPrefs.SetInt("resolutiontype", 1);
        PlayerPrefs.SetInt("graphictype", 1);
        Screen.SetResolution(1280, 720, true);
    }

The game crashes when I try to set it to HIGH. What’s wrong?

[quote=“magsoftware, post:1, topic: 894875, username:magsoftware”]
When I play the game on my Android device, I cannot see its memory… The coroutine isn’t running or something… Why?
[/quote]Could it be that the coroutine is running but the Android device is falling in the 2048 → 4000 range?

I fixed this error many days ago and that was the problem. Thanks anyway

1 Like