< prev index next >

src/hotspot/share/services/management.cpp

Print this page

2077   if (cmdline == nullptr) {
2078     THROW_MSG_NULL(vmSymbols::java_lang_NullPointerException(),
2079                    "Command line content cannot be null.");
2080   }
2081   bufferedStream output;
2082   DCmd::parse_and_execute(DCmd_Source_MBean, &output, cmdline, ' ', CHECK_NULL);
2083   oop result = java_lang_String::create_oop_from_str(output.as_string(), CHECK_NULL);
2084   return (jstring) JNIHandles::make_local(THREAD, result);
2085 JVM_END
2086 
2087 JVM_ENTRY(void, jmm_SetDiagnosticFrameworkNotificationEnabled(JNIEnv *env, jboolean enabled))
2088   DCmdFactory::set_jmx_notification_enabled(enabled?true:false);
2089 JVM_END
2090 
2091 jlong Management::ticks_to_ms(jlong ticks) {
2092   assert(os::elapsed_frequency() > 0, "Must be non-zero");
2093   return (jlong)(((double)ticks / (double)os::elapsed_frequency())
2094                  * (double)1000.0);
2095 }
2096 






2097 // Gets the amount of memory allocated on the Java heap since JVM launch.
2098 JVM_ENTRY(jlong, jmm_GetTotalThreadAllocatedMemory(JNIEnv *env))
2099     // A thread increments exited_allocated_bytes in ThreadService::remove_thread
2100     // only after it removes itself from the threads list, and once a TLH is
2101     // created, no thread it references can remove itself from the threads
2102     // list, so none can update exited_allocated_bytes. We therefore initialize
2103     // result with exited_allocated_bytes after after we create the TLH so that
2104     // the final result can only be short due to (1) threads that start after
2105     // the TLH is created, or (2) terminating threads that escape TLH creation
2106     // and don't update exited_allocated_bytes before we initialize result.
2107 
2108     // We keep a high water mark to ensure monotonicity in case threads counted
2109     // on a previous call end up in state (2).
2110     static jlong high_water_result = 0;
2111 
2112     JavaThreadIteratorWithHandle jtiwh;
2113     jlong result = ThreadService::exited_allocated_bytes();
2114     for (; JavaThread* thread = jtiwh.next();) {
2115       jlong size = thread->cooked_allocated_bytes();
2116       result += size;

2077   if (cmdline == nullptr) {
2078     THROW_MSG_NULL(vmSymbols::java_lang_NullPointerException(),
2079                    "Command line content cannot be null.");
2080   }
2081   bufferedStream output;
2082   DCmd::parse_and_execute(DCmd_Source_MBean, &output, cmdline, ' ', CHECK_NULL);
2083   oop result = java_lang_String::create_oop_from_str(output.as_string(), CHECK_NULL);
2084   return (jstring) JNIHandles::make_local(THREAD, result);
2085 JVM_END
2086 
2087 JVM_ENTRY(void, jmm_SetDiagnosticFrameworkNotificationEnabled(JNIEnv *env, jboolean enabled))
2088   DCmdFactory::set_jmx_notification_enabled(enabled?true:false);
2089 JVM_END
2090 
2091 jlong Management::ticks_to_ms(jlong ticks) {
2092   assert(os::elapsed_frequency() > 0, "Must be non-zero");
2093   return (jlong)(((double)ticks / (double)os::elapsed_frequency())
2094                  * (double)1000.0);
2095 }
2096 
2097 jlong Management::ticks_to_us(jlong ticks) {
2098   assert(os::elapsed_frequency() > 0, "Must be non-zero");
2099   return (jlong)(((double)ticks / (double)os::elapsed_frequency())
2100                  * (double)1000000.0);
2101 }
2102 
2103 // Gets the amount of memory allocated on the Java heap since JVM launch.
2104 JVM_ENTRY(jlong, jmm_GetTotalThreadAllocatedMemory(JNIEnv *env))
2105     // A thread increments exited_allocated_bytes in ThreadService::remove_thread
2106     // only after it removes itself from the threads list, and once a TLH is
2107     // created, no thread it references can remove itself from the threads
2108     // list, so none can update exited_allocated_bytes. We therefore initialize
2109     // result with exited_allocated_bytes after after we create the TLH so that
2110     // the final result can only be short due to (1) threads that start after
2111     // the TLH is created, or (2) terminating threads that escape TLH creation
2112     // and don't update exited_allocated_bytes before we initialize result.
2113 
2114     // We keep a high water mark to ensure monotonicity in case threads counted
2115     // on a previous call end up in state (2).
2116     static jlong high_water_result = 0;
2117 
2118     JavaThreadIteratorWithHandle jtiwh;
2119     jlong result = ThreadService::exited_allocated_bytes();
2120     for (; JavaThread* thread = jtiwh.next();) {
2121       jlong size = thread->cooked_allocated_bytes();
2122       result += size;
< prev index next >