Finding app heap availability

VMRuntime was a great class provided in Android SDK to find and alter information about the VM used by your application.

However, this has been deprecated since version 5 mentioning this was only intended for Internal usage and not for public usage. That;s sad since we cannot find useful functions elsewhere.

If you do want to find memory consumption of the system, you can use:

ActivityManager actvityManager = (ActivityManager) this.getSystemService( ACTIVITY_SERVICE );
ActivityManager.MemoryInfo mInfo = new ActivityManager.MemoryInfo ();
actvityManager.getMemoryInfo( mInfo );
Log.i(TAG, " minfo.availMem " + mInfo.availMem);
Log.i(TAG, " minfo.lowMemory " + mInfo.lowMemory);
Log.i(TAG, " minfo.threshold " + mInfo.threshold);

If you are looking for information for your app, you can use the java provided Runtime methods:

Log.i("AvailableHeapMemory", " Runtime.getRuntime().freeMemory() "
        + Runtime.getRuntime().freeMemory());
Log.i("AvailableHeapMemory", " Runtime.getRuntime().maxMemory() "
        + Runtime.getRuntime().maxMemory());
Log.i("AvailableHeapMemory", " Runtime.getRuntime().totalMemory() "
        + Runtime.getRuntime().totalMemory());