ActivityManager manager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
int heapSize = manager.getMemoryClass();
就能获取当前手机的堆大小了, 单位是MB
这个就是每个程序可使用的内存上限, 开发应用程序时所使用的内存不能超出这个限制,否则就会出现OutOfMemoryError.
ActivityManager manager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
int heapSize = manager.getMemoryClass();
就能获取当前手机的堆大小了, 单位是MB
这个就是每个程序可使用的内存上限, 开发应用程序时所使用的内存不能超出这个限制,否则就会出现OutOfMemoryError.