Conversation
| } | ||
|
|
||
| jlongArray RetainedSizeByClassLoadersAction::executeOperation(jobjectArray classLoadersArray) { | ||
| std::vector <jlong> result; |
| handleError(jvmti, err, "Could not estimate retained size by classLoaders"); | ||
| return env->NewLongArray(0); | ||
| } | ||
| std::cout << "HEAP SIZE: " << getHeapSize() << std::endl; |
There was a problem hiding this comment.
Since memory agent is a library, it would be better not to pollute stdout, but instead return the result in the format of nested arrays: [[class loaders sizes as jlongs], [other classes size]]
| private: | ||
| jlongArray executeOperation(jobjectArray classLoadersArray) override; | ||
| jvmtiError getRetainedSizeByClassLoaders(jobjectArray classLoadersArray, std::vector<jlong> &result); | ||
| jvmtiError tagObjectsByClassLoader(jclass *classes, jint* cnt, jobject classLoader, jsize classLoaderIndex); |
There was a problem hiding this comment.
Asterisks should stick to the variable name
| jvmtiError getRetainedSizeByClassLoaders(jobjectArray classLoadersArray, std::vector<jlong> &result); | ||
| jvmtiError tagObjectsByClassLoader(jclass *classes, jint* cnt, jobject classLoader, jsize classLoaderIndex); | ||
| jlong getHeapSize(); | ||
| jlong tagOtherObjects(jclass *classes, jint* cnt, jobjectArray classLoadersArray); |
There was a problem hiding this comment.
Asterisks should stick to the variable name
| return res; | ||
| } | ||
|
|
||
| jobjectArray toJavaArray(JNIEnv *env, std::vector <jclass> &objects) { |
| return resultArray; | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
The formatting is a little off here
| result.resize(env->GetArrayLength(classLoadersArray) + 1); | ||
| err = IterateThroughHeap(JVMTI_HEAP_FILTER_UNTAGGED, nullptr, visitObject, result.data(), | ||
| "calculate retained size"); | ||
| return err; |
There was a problem hiding this comment.
return IterateThroughHeap(JVMTI_HEAP_FILTER_UNTAGGED, nullptr, visitObject, result.data(),
"calculate retained size");
| err = jvmti->GetLoadedClasses(&cnt, &classes); | ||
| std::cout << cnt << std::endl; | ||
| for (jsize i = 0; i < env->GetArrayLength(classLoadersArray); i++) { | ||
| jvmtiError err = tagObjectsByClassLoader(classes, &cnt, env->GetObjectArrayElement(classLoadersArray, i), i); |
There was a problem hiding this comment.
if (!isOk(err)) return err
There was a problem hiding this comment.
Also there's no need to declare a new variable here
| for (jsize i = 0; i < env->GetArrayLength(classLoadersArray); i++) { | ||
| jvmtiError err = tagObjectsByClassLoader(classes, &cnt, env->GetObjectArrayElement(classLoadersArray, i), i); | ||
| } | ||
| tagOtherObjects(classes, &cnt, classLoadersArray); |
There was a problem hiding this comment.
err = tagOtherObjects(classes, &cnt, classLoadersArray);
if (!isOk(err)) return err
| jlong tagOtherObjects(jclass *classes, jint* cnt, jobjectArray classLoadersArray); | ||
| }; | ||
|
|
||
| jint JNICALL visitObject(jlong classTag, jlong size, jlong *tagPtr, jint length, void *userData); |
There was a problem hiding this comment.
I think this function should not be declared here
No description provided.