< prev index next >

src/hotspot/share/services/management.cpp

Print this page

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






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

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