MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / dump

Method dump

src/objectSampler.cpp:97–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95 }
96
97 void dump(JNIEnv* jni) {
98 _lock.lock();
99
100 jvmtiEnv* jvmti = VM::jvmti();
101 Profiler* profiler = Profiler::instance();
102
103 // Reset counters before dumping to collect live objects only.
104 profiler->tryResetCounters();
105
106 for (u32 i = 0; i < MAX_REFS; i++) {
107 if ((i % 32) == 0) jni->PushLocalFrame(64);
108
109 jweak w = _refs[i];
110 if (w != NULL) {
111 jobject obj = jni->NewLocalRef(w);
112 if (obj != NULL) {
113 LiveObject event;
114 event._start_time = TSC::ticks();
115 event._alloc_size = _values[i].size;
116 event._alloc_time = _values[i].time;
117 event._class_id = lookupClassId(jvmti, jni->GetObjectClass(obj));
118
119 int tid = _values[i].trace >> 32;
120 u32 call_trace_id = (u32)_values[i].trace;
121 profiler->recordExternalSamples(1, event._alloc_size, tid, call_trace_id, LIVE_OBJECT, &event);
122 }
123 jni->DeleteWeakGlobalRef(w);
124 }
125
126 if ((i % 32) == 31 || i == MAX_REFS - 1) jni->PopLocalFrame(NULL);
127 }
128 }
129};
130
131static LiveRefs live_refs;

Callers 1

dumpLiveRefsMethod · 0.45

Calls 4

lookupClassIdFunction · 0.85
tryResetCountersMethod · 0.80
recordExternalSamplesMethod · 0.80
lockMethod · 0.45

Tested by

no test coverage detected