Search Unity

SystemInfo returning wrong values on Note3 and newer devices

Discussion in 'Android' started by 2600th, Jan 7, 2014.

  1. 2600th

    2600th

    Joined:
    Jan 7, 2014
    Posts:
    5
    SystemInfo.systemMemorySize returns negative value (-1784) on Note 3 and SystemInfo.graphicsMemorySize returns value of zero on same. Is there any other way to get the amount of memory available on these devices. Thanks!
     
    Last edited: Jan 7, 2014
  2. Agent_007

    Agent_007

    Joined:
    Dec 18, 2011
    Posts:
    899
  3. 2600th

    2600th

    Joined:
    Jan 7, 2014
    Posts:
    5
    Last edited: Jan 8, 2014
  4. bitter

    bitter

    Unity Technologies

    Joined:
    Jan 11, 2012
    Posts:
    530
    What Unity version? If it's Unity 4.3 could you please file a bug on that?
     
  5. 2600th

    2600th

    Joined:
    Jan 7, 2014
    Posts:
    5
    @bitter I'm using Unity3d 4.3.2f1. I filed a bug using Report a bug inside editor. On a side note here's some explanation about the same : Note3 has 3GByte of RAM and the systemMemorySize is of type 'int'. So the correct size is 2^32 - 1784 * 2^20.
     
    tms_dev likes this.
  6. cdr9042

    cdr9042

    Joined:
    Apr 22, 2018
    Posts:
    173
    Can you share the plugin please? I tried to write a Java class but I ran into the error "java.lang.IllegalStateException: System services not available to Activities before onCreate()" when I try to call the function

    This is my Java file
    Code (CSharp):
    1. package com.DefaultCompany.MemoryTest;
    2. import com.unity3d.player.UnityPlayerActivity;
    3. import android.os.Bundle;
    4. import android.util.Log;
    5. import android.os.Bundle;
    6. import android.util.Log;
    7. import android.app.ActivityManager;
    8. import android.app.ActivityManager.MemoryInfo;
    9. import androidx.appcompat.app.AppCompatActivity;
    10.  
    11.  
    12. public class MemoryInfoChecker extends UnityPlayerActivity {
    13.   protected void onCreate(Bundle savedInstanceState) {
    14.     // Calls UnityPlayerActivity.onCreate()
    15.     super.onCreate(savedInstanceState);
    16.     // Prints debug message to Logcat
    17.     Log.d("OverrideActivity", "onCreate called!");
    18.   }
    19.   public double[] getMemoryInfo() {
    20.     ActivityManager activityManager = (ActivityManager ) super.getSystemService("ACTIVITY_SERVICE");
    21.     MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
    22.     activityManager.getMemoryInfo(memoryInfo);
    23.     double[] values = new double[2];
    24.     values[0] = memoryInfo.availMem;
    25.     values[1] = memoryInfo.totalMem;
    26.     return values;
    27.   }
    28. }