Below is my formula to check how much memory is remaining (not how much memory remains in the current heap, but how much more memory may be utilized before the application crashes). I'm not remotely sure this is correct, is it?
double max = Runtime.getRuntime().maxMemory(); //the maximum memory the app can use
double heapSize = Runtime.getRuntime().totalMemory(); //current heap size
double heapRemaining = Runtime.getRuntime().freeMemory(); //amount available in heap
double nativeUsage = Debug.getNativeHeapAllocatedSize(); //is this right? I only want to account for native memory that my app is being "charged" for. Is this the proper way to account for that?
//heapSize - heapRemaining = heapUsed + nativeUsage = totalUsage
double remaining = max - (heapSize - heapRemaininng + nativeUsage);
getNativeHeapFreeSize()
goo.gl/wsBKT not what you wanted? – Belden