-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retained size by ClassLoaders #35
base: master
Are you sure you want to change the base?
Retained size by ClassLoaders #35
Conversation
} | ||
|
||
jlongArray RetainedSizeByClassLoadersAction::executeOperation(jobjectArray classLoadersArray) { | ||
std::vector <jlong> result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An extra space
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Asterisks should stick to the variable name
@@ -49,6 +49,15 @@ jobjectArray toJavaArray(JNIEnv *env, std::vector<jobject> &objects) { | |||
return res; | |||
} | |||
|
|||
jobjectArray toJavaArray(JNIEnv *env, std::vector <jclass> &objects) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An extra space
@@ -97,6 +97,14 @@ public synchronized <T> T[] getAllReachableObjects(Object startObject, Class<T> | |||
return resultArray; | |||
} | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!isOk(err)) return err
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function should not be declared here
No description provided.