< prev index next >

src/hotspot/share/services/attachListener.cpp

Print this page

        

*** 246,284 **** // See also: ClassHistogramDCmd class // // Input arguments :- // arg0: "-live" or "-all" // arg1: Name of the dump file or NULL static jint heap_inspection(AttachOperation* op, outputStream* out) { bool live_objects_only = true; // default is true to retain the behavior before this change is made outputStream* os = out; // if path not specified or path is NULL, use out fileStream* fs = NULL; const char* arg0 = op->arg(0); if (arg0 != NULL && (strlen(arg0) > 0)) { if (strcmp(arg0, "-all") != 0 && strcmp(arg0, "-live") != 0) { out->print_cr("Invalid argument to inspectheap operation: %s", arg0); return JNI_ERR; } live_objects_only = strcmp(arg0, "-live") == 0; } const char* path = op->arg(1); ! if (path != NULL) { ! if (path[0] == '\0') { ! out->print_cr("No dump file specified"); ! } else { // create file fs = new (ResourceObj::C_HEAP, mtInternal) fileStream(path); if (fs == NULL) { out->print_cr("Failed to allocate space for file: %s", path); - return JNI_ERR; } os = fs; } } ! VM_GC_HeapInspection heapop(os, live_objects_only /* request full gc */); VMThread::execute(&heapop); if (os != NULL && os != out) { out->print_cr("Heap inspection file created: %s", path); delete fs; } --- 246,291 ---- // See also: ClassHistogramDCmd class // // Input arguments :- // arg0: "-live" or "-all" // arg1: Name of the dump file or NULL + // arg2: parallel thread number static jint heap_inspection(AttachOperation* op, outputStream* out) { bool live_objects_only = true; // default is true to retain the behavior before this change is made outputStream* os = out; // if path not specified or path is NULL, use out fileStream* fs = NULL; const char* arg0 = op->arg(0); + uint parallel_thread_num = MAX(1, os::initial_active_processor_count() * 3 / 8); // default is less than half of processors. if (arg0 != NULL && (strlen(arg0) > 0)) { if (strcmp(arg0, "-all") != 0 && strcmp(arg0, "-live") != 0) { out->print_cr("Invalid argument to inspectheap operation: %s", arg0); return JNI_ERR; } live_objects_only = strcmp(arg0, "-live") == 0; } const char* path = op->arg(1); ! if (path != NULL && path[0] != '\0') { // create file fs = new (ResourceObj::C_HEAP, mtInternal) fileStream(path); if (fs == NULL) { out->print_cr("Failed to allocate space for file: %s", path); } os = fs; } + + const char* num_str = op->arg(2); + if (num_str != NULL && num_str[0] != '\0') { + uintx num; + if (!Arguments::parse_uintx(num_str, &num, 0)) { + out->print_cr("Invalid parallel thread number: [%s]", num_str); + return JNI_ERR; + } + parallel_thread_num = num == 0 ? parallel_thread_num : num; } ! VM_GC_HeapInspection heapop(os, live_objects_only /* request full gc */, parallel_thread_num); VMThread::execute(&heapop); if (os != NULL && os != out) { out->print_cr("Heap inspection file created: %s", path); delete fs; }
< prev index next >