Add support for tracking jvmti allocations
Adds a jvmti extension for getting the amount of memory allocated and
by jvmtiEnvs and currently live.
Bug: 62065509
Test: ./test.py --host -j40
Change-Id: I5d05b171260d91f9c415f7a5cb40cc01b48d7d07
diff --git a/runtime/openjdkjvmti/ti_allocator.h b/runtime/openjdkjvmti/ti_allocator.h
index 7f1aa6d..aba77ae 100644
--- a/runtime/openjdkjvmti/ti_allocator.h
+++ b/runtime/openjdkjvmti/ti_allocator.h
@@ -35,12 +35,17 @@
#include "jni.h"
#include "jvmti.h"
+#include <atomic>
+
namespace openjdkjvmti {
class AllocUtil {
public:
static jvmtiError Allocate(jvmtiEnv* env, jlong size, unsigned char** mem_ptr);
static jvmtiError Deallocate(jvmtiEnv* env, unsigned char* mem);
+ static jvmtiError GetGlobalJvmtiAllocationState(jvmtiEnv* env, jlong* total_allocated);
+ private:
+ static std::atomic<jlong> allocated;
};
} // namespace openjdkjvmti