< prev index next >

src/hotspot/share/services/management.cpp

Print this page

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






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

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