引入:jvm
上文中咱們討論了Agent利用環境指針訪問VM的堆棧操做部分,這裏咱們討論堆操做部分。
ide
分類5:堆操做指針
a. GetTag. 獲取對象在堆上的惟一標識符(長整型)。對象
jvmtiError GetTag(jvmtiEnv* env, jobject object, jlong* tag_ptr)
b.SetTag.爲對象設置堆上的惟一標示符。it
jvmtiError SetTag(jvmtiEnv* env, jobject object, jlong tag)
c.ForceGarbageCollection. 強制VM執行垃圾回收。io
jvmtiError ForceGarbageCollection(jvmtiEnv* env)
該方法只有等垃圾回收作完才返回。class
d.IterateOverObjectsReachableFromObject. 迭代某對象所能直接或者間接引用到的全部對象。object
jvmtiError IterateOverObjectsReachableFromObject(jvmtiEnv* env, jobject object, jvmtiObjectReferenceCallback object_reference_callback, void* user_data)
e.IterateOverReachableObjects.迭代堆上全部能夠引用到的對象。垃圾回收
jvmtiError IterateOverReachableObjects(jvmtiEnv* env, jvmtiHeapRootCallback heap_root_callback, jvmtiStackReferenceCallback stack_ref_callback, jvmtiObjectReferenceCallback object_ref_callback, void* user_data)
f.IterateOverHeap.迭代堆上的全部對象,包含能夠到達的和不可到達的。引用
jvmtiError IterateOverHeap(jvmtiEnv* env, jvmtiHeapObjectFilter object_filter, jvmtiHeapObjectCallback heap_object_callback, void* user_data)
g.IterateOverInstancesOfClass.迭代某個給定的類的堆上全部實例。包括能夠和不能夠到達的。
jvmtiError IterateOverInstancesOfClass(jvmtiEnv* env, jclass klass, jvmtiHeapObjectFilter object_filter, jvmtiHeapObjectCallback heap_object_callback, void* user_data)
h.GetObjectsWithTags.獲取給定的堆標記的對象列表。
jvmtiError GetObjectsWithTags(jvmtiEnv* env, jint tag_count, const jlong* tags, jint* count_ptr, jobject** object_result_ptr, jlong** tag_result_ptr)