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!
You could write a plugin for that
http://stackoverflow.com/questions/7374246/how-to-get-total-ram-size-of-a-device
I wrote a plugin using this piece of code api - Android How do you get total memory RAM in the device? - Stack Overflow since MemoryInfo requires API 16. Thanks!
What Unity version? If it’s Unity 4.3 could you please file a bug on that?
@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.
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
package com.DefaultCompany.MemoryTest;
import com.unity3d.player.UnityPlayerActivity;
import android.os.Bundle;
import android.util.Log;
import android.os.Bundle;
import android.util.Log;
import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo;
import androidx.appcompat.app.AppCompatActivity;
public class MemoryInfoChecker extends UnityPlayerActivity {
protected void onCreate(Bundle savedInstanceState) {
// Calls UnityPlayerActivity.onCreate()
super.onCreate(savedInstanceState);
// Prints debug message to Logcat
Log.d("OverrideActivity", "onCreate called!");
}
public double[] getMemoryInfo() {
ActivityManager activityManager = (ActivityManager ) super.getSystemService("ACTIVITY_SERVICE");
MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
activityManager.getMemoryInfo(memoryInfo);
double[] values = new double[2];
values[0] = memoryInfo.availMem;
values[1] = memoryInfo.totalMem;
return values;
}
}