Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc323654 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Annotate android.os.Debug native heap accessors with @CriticalNative" into main

parents 784cc39a 3ebd97e3
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.internal.util.FastPrintWriter;
import com.android.internal.util.Preconditions;
import com.android.internal.util.TypedProperties;

import dalvik.annotation.optimization.CriticalNative;
import dalvik.system.VMDebug;

import org.apache.harmony.dalvik.ddmc.Chunk;
@@ -1936,18 +1937,21 @@ public final class Debug
     * Returns the size of the native heap.
     * @return The size of the native heap in bytes.
     */
    @CriticalNative
    public static native long getNativeHeapSize();

    /**
     * Returns the amount of allocated memory in the native heap.
     * @return The allocated size in bytes.
     */
    @CriticalNative
    public static native long getNativeHeapAllocatedSize();

    /**
     * Returns the amount of free memory in the native heap.
     * @return The freed size in bytes.
     */
    @CriticalNative
    public static native long getNativeHeapFreeSize();

    /**
+5 −3
Original line number Diff line number Diff line
@@ -51,10 +51,12 @@
#include <utils/misc.h>
#include <vintf/KernelConfigs.h>


#include <iomanip>
#include <string>
#include <vector>

#include "core_jni_helpers.h"
#include "jni.h"

namespace android
@@ -102,19 +104,19 @@ static jfieldID hasSwappedOutPss_field;

#define BINDER_STATS "/proc/binder/stats"

static jlong android_os_Debug_getNativeHeapSize(JNIEnv *env, jobject clazz)
static jlong android_os_Debug_getNativeHeapSize(CRITICAL_JNI_PARAMS)
{
    struct mallinfo info = mallinfo();
    return (jlong) info.usmblks;
}

static jlong android_os_Debug_getNativeHeapAllocatedSize(JNIEnv *env, jobject clazz)
static jlong android_os_Debug_getNativeHeapAllocatedSize(CRITICAL_JNI_PARAMS)
{
    struct mallinfo info = mallinfo();
    return (jlong) info.uordblks;
}

static jlong android_os_Debug_getNativeHeapFreeSize(JNIEnv *env, jobject clazz)
static jlong android_os_Debug_getNativeHeapFreeSize(CRITICAL_JNI_PARAMS)
{
    struct mallinfo info = mallinfo();
    return (jlong) info.fordblks;