Skip to content

Instantly share code, notes, and snippets.

@Morfly
Last active November 8, 2022 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Morfly/c8c85b4912a0fdab1c77bcf1974f35ac to your computer and use it in GitHub Desktop.
Save Morfly/c8c85b4912a0fdab1c77bcf1974f35ac to your computer and use it in GitHub Desktop.
import android.os.Debug.MemoryInfo
val activityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
val pid = intArrayOf(android.os.Process.myPid())
// The sample rate for calling this API is limited to once per 5 minutes.
// If called more frequently, it returns the same data as pverious call.
val memoryInfo: MemoryInfo = activityManager.getProcessMemoryInfo(pid).first()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment