1 // Copyright 2015 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/android/java_runtime.h"
7 #include "base/android_runtime_jni_headers/Runtime_jni.h"
8 #include "base/numerics/safe_conversions.h"
13 void JavaRuntime::GetMemoryUsage(uint64_t* total_memory,
14 uint64_t* free_memory) {
15 JNIEnv* env = base::android::AttachCurrentThread();
16 base::android::ScopedJavaLocalRef<jobject> runtime =
17 JNI_Runtime::Java_Runtime_getRuntime(env);
18 *total_memory = checked_cast<uint64_t>(
19 JNI_Runtime::Java_Runtime_totalMemory(env, runtime));
20 *free_memory = checked_cast<uint64_t>(
21 JNI_Runtime::Java_Runtime_freeMemory(env, runtime));
24 } // namespace android