15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/systemDictionary.hpp"
27 #include "classfile/vmSymbols.hpp"
28 #include "gc/parallel/mutableSpace.hpp"
29 #include "gc/serial/defNewGeneration.hpp"
30 #include "gc/serial/tenuredGeneration.hpp"
31 #include "gc/shared/collectorPolicy.hpp"
32 #include "gc/shared/genCollectedHeap.hpp"
33 #include "gc/shared/generation.hpp"
34 #include "gc/shared/generationSpec.hpp"
35 #include "memory/heap.hpp"
36 #include "memory/memRegion.hpp"
37 #include "oops/oop.inline.hpp"
38 #include "runtime/globals.hpp"
39 #include "runtime/javaCalls.hpp"
40 #include "services/classLoadingService.hpp"
41 #include "services/lowMemoryDetector.hpp"
42 #include "services/management.hpp"
43 #include "services/memoryManager.hpp"
44 #include "services/memoryPool.hpp"
45 #include "services/memoryService.hpp"
46 #include "utilities/growableArray.hpp"
47 #include "utilities/macros.hpp"
48 #if INCLUDE_ALL_GCS
49 #include "gc/cms/concurrentMarkSweepGeneration.hpp"
50 #include "gc/cms/parNewGeneration.hpp"
51 #include "gc/g1/g1CollectedHeap.inline.hpp"
52 #include "gc/parallel/parallelScavengeHeap.hpp"
53 #include "gc/parallel/psOldGen.hpp"
54 #include "gc/parallel/psYoungGen.hpp"
500 mgr->gc_end(recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
501 countCollection, cause);
502 }
503
504 void MemoryService::oops_do(OopClosure* f) {
505 int i;
506
507 for (i = 0; i < _pools_list->length(); i++) {
508 MemoryPool* pool = _pools_list->at(i);
509 pool->oops_do(f);
510 }
511 for (i = 0; i < _managers_list->length(); i++) {
512 MemoryManager* mgr = _managers_list->at(i);
513 mgr->oops_do(f);
514 }
515 }
516
517 bool MemoryService::set_verbose(bool verbose) {
518 MutexLocker m(Management_lock);
519 // verbose will be set to the previous value
520 Flag::Error error = CommandLineFlags::boolAtPut("PrintGC", &verbose, Flag::MANAGEMENT);
521 assert(error==Flag::SUCCESS, "Setting PrintGC flag failed with error %s", Flag::flag_error_str(error));
522 ClassLoadingService::reset_trace_class_unloading();
523
524 return verbose;
525 }
526
527 Handle MemoryService::create_MemoryUsage_obj(MemoryUsage usage, TRAPS) {
528 Klass* k = Management::java_lang_management_MemoryUsage_klass(CHECK_NH);
529 instanceKlassHandle ik(THREAD, k);
530
531 instanceHandle obj = ik->allocate_instance_handle(CHECK_NH);
532
533 JavaValue result(T_VOID);
534 JavaCallArguments args(10);
535 args.push_oop(obj); // receiver
536 args.push_long(usage.init_size_as_jlong()); // Argument 1
537 args.push_long(usage.used_as_jlong()); // Argument 2
538 args.push_long(usage.committed_as_jlong()); // Argument 3
539 args.push_long(usage.max_size_as_jlong()); // Argument 4
540
541 JavaCalls::call_special(&result,
|
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/systemDictionary.hpp"
27 #include "classfile/vmSymbols.hpp"
28 #include "gc/parallel/mutableSpace.hpp"
29 #include "gc/serial/defNewGeneration.hpp"
30 #include "gc/serial/tenuredGeneration.hpp"
31 #include "gc/shared/collectorPolicy.hpp"
32 #include "gc/shared/genCollectedHeap.hpp"
33 #include "gc/shared/generation.hpp"
34 #include "gc/shared/generationSpec.hpp"
35 #include "logging/logConfiguration.hpp"
36 #include "memory/heap.hpp"
37 #include "memory/memRegion.hpp"
38 #include "oops/oop.inline.hpp"
39 #include "runtime/globals.hpp"
40 #include "runtime/javaCalls.hpp"
41 #include "services/classLoadingService.hpp"
42 #include "services/lowMemoryDetector.hpp"
43 #include "services/management.hpp"
44 #include "services/memoryManager.hpp"
45 #include "services/memoryPool.hpp"
46 #include "services/memoryService.hpp"
47 #include "utilities/growableArray.hpp"
48 #include "utilities/macros.hpp"
49 #if INCLUDE_ALL_GCS
50 #include "gc/cms/concurrentMarkSweepGeneration.hpp"
51 #include "gc/cms/parNewGeneration.hpp"
52 #include "gc/g1/g1CollectedHeap.inline.hpp"
53 #include "gc/parallel/parallelScavengeHeap.hpp"
54 #include "gc/parallel/psOldGen.hpp"
55 #include "gc/parallel/psYoungGen.hpp"
501 mgr->gc_end(recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
502 countCollection, cause);
503 }
504
505 void MemoryService::oops_do(OopClosure* f) {
506 int i;
507
508 for (i = 0; i < _pools_list->length(); i++) {
509 MemoryPool* pool = _pools_list->at(i);
510 pool->oops_do(f);
511 }
512 for (i = 0; i < _managers_list->length(); i++) {
513 MemoryManager* mgr = _managers_list->at(i);
514 mgr->oops_do(f);
515 }
516 }
517
518 bool MemoryService::set_verbose(bool verbose) {
519 MutexLocker m(Management_lock);
520 // verbose will be set to the previous value
521 if (verbose) {
522 LogConfiguration::parse_log_arguments("stdout", "gc", NULL, NULL, NULL);
523 } else {
524 LogConfiguration::parse_log_arguments("stdout", "gc=off", NULL, NULL, NULL);
525 }
526 ClassLoadingService::reset_trace_class_unloading();
527
528 return verbose;
529 }
530
531 Handle MemoryService::create_MemoryUsage_obj(MemoryUsage usage, TRAPS) {
532 Klass* k = Management::java_lang_management_MemoryUsage_klass(CHECK_NH);
533 instanceKlassHandle ik(THREAD, k);
534
535 instanceHandle obj = ik->allocate_instance_handle(CHECK_NH);
536
537 JavaValue result(T_VOID);
538 JavaCallArguments args(10);
539 args.push_oop(obj); // receiver
540 args.push_long(usage.init_size_as_jlong()); // Argument 1
541 args.push_long(usage.used_as_jlong()); // Argument 2
542 args.push_long(usage.committed_as_jlong()); // Argument 3
543 args.push_long(usage.max_size_as_jlong()); // Argument 4
544
545 JavaCalls::call_special(&result,
|