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