src/share/vm/services/heapDumper.cpp

Print this page


   1 /*
   2  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  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  *


1380   void add_class_serial_number(Klass* k, int serial_num) {
1381     _klass_map->at_put_grow(serial_num, k);
1382   }
1383 
1384   // HPROF_TRACE and HPROF_FRAME records
1385   void dump_stack_traces();
1386 
1387   // writes a HPROF_HEAP_DUMP or HPROF_HEAP_DUMP_SEGMENT record
1388   void write_dump_header();
1389 
1390   // fixes up the length of the current dump record
1391   void write_current_dump_record_length();
1392 
1393   // fixes up the current dump record )and writes HPROF_HEAP_DUMP_END
1394   // record in the case of a segmented heap dump)
1395   void end_of_dump();
1396 
1397  public:
1398   VM_HeapDumper(DumpWriter* writer, bool gc_before_heap_dump, bool oome) :
1399     VM_GC_Operation(0 /* total collections,      dummy, ignored */,

1400                     0 /* total full collections, dummy, ignored */,
1401                     gc_before_heap_dump) {
1402     _local_writer = writer;
1403     _gc_before_heap_dump = gc_before_heap_dump;
1404     _is_segmented_dump = false;
1405     _dump_start = (jlong)-1;
1406     _klass_map = new (ResourceObj::C_HEAP) GrowableArray<Klass*>(INITIAL_CLASS_COUNT, true);
1407     _stack_traces = NULL;
1408     _num_threads = 0;
1409     if (oome) {
1410       assert(!Thread::current()->is_VM_thread(), "Dump from OutOfMemoryError cannot be called by the VMThread");
1411       // get OutOfMemoryError zero-parameter constructor
1412       instanceKlass* oome_ik = instanceKlass::cast(SystemDictionary::OutOfMemoryError_klass());
1413       _oome_constructor = oome_ik->find_method(vmSymbols::object_initializer_name(),
1414                                                           vmSymbols::void_method_signature());
1415       // get thread throwing OOME when generating the heap dump at OOME
1416       _oome_thread = JavaThread::current();
1417     } else {
1418       _oome_thread = NULL;
1419       _oome_constructor = NULL;


   1 /*
   2  * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  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  *


1380   void add_class_serial_number(Klass* k, int serial_num) {
1381     _klass_map->at_put_grow(serial_num, k);
1382   }
1383 
1384   // HPROF_TRACE and HPROF_FRAME records
1385   void dump_stack_traces();
1386 
1387   // writes a HPROF_HEAP_DUMP or HPROF_HEAP_DUMP_SEGMENT record
1388   void write_dump_header();
1389 
1390   // fixes up the length of the current dump record
1391   void write_current_dump_record_length();
1392 
1393   // fixes up the current dump record )and writes HPROF_HEAP_DUMP_END
1394   // record in the case of a segmented heap dump)
1395   void end_of_dump();
1396 
1397  public:
1398   VM_HeapDumper(DumpWriter* writer, bool gc_before_heap_dump, bool oome) :
1399     VM_GC_Operation(0 /* total collections,      dummy, ignored */,
1400                     GCCause::_heap_dump /* GC Cause */,
1401                     0 /* total full collections, dummy, ignored */,
1402                     gc_before_heap_dump) {
1403     _local_writer = writer;
1404     _gc_before_heap_dump = gc_before_heap_dump;
1405     _is_segmented_dump = false;
1406     _dump_start = (jlong)-1;
1407     _klass_map = new (ResourceObj::C_HEAP) GrowableArray<Klass*>(INITIAL_CLASS_COUNT, true);
1408     _stack_traces = NULL;
1409     _num_threads = 0;
1410     if (oome) {
1411       assert(!Thread::current()->is_VM_thread(), "Dump from OutOfMemoryError cannot be called by the VMThread");
1412       // get OutOfMemoryError zero-parameter constructor
1413       instanceKlass* oome_ik = instanceKlass::cast(SystemDictionary::OutOfMemoryError_klass());
1414       _oome_constructor = oome_ik->find_method(vmSymbols::object_initializer_name(),
1415                                                           vmSymbols::void_method_signature());
1416       // get thread throwing OOME when generating the heap dump at OOME
1417       _oome_thread = JavaThread::current();
1418     } else {
1419       _oome_thread = NULL;
1420       _oome_constructor = NULL;