8148755: -XX:+HeapDumpAfterFullGC creates heap dump both before and after Full GC
authorredestad
Wed, 03 Feb 2016 14:15:57 +0100
changeset 35915 5808cd93abfc
parent 35914 aab83fe79386
child 35916 23189249c2c1
child 35918 1e48ea715a0b
child 35920 a107472364cc
8148755: -XX:+HeapDumpAfterFullGC creates heap dump both before and after Full GC Reviewed-by: mgerdin, brutisso, sangheki
hotspot/src/share/vm/gc/shared/collectedHeap.cpp
hotspot/src/share/vm/gc/shared/collectedHeap.hpp
--- a/hotspot/src/share/vm/gc/shared/collectedHeap.cpp	Tue Feb 02 22:12:17 2016 -0500
+++ b/hotspot/src/share/vm/gc/shared/collectedHeap.cpp	Wed Feb 03 14:15:57 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -571,10 +571,10 @@
   }
 }
 
-void CollectedHeap::full_gc_dump(GCTimer* timer, const char* when) {
-  if (HeapDumpBeforeFullGC || HeapDumpAfterFullGC) {
+void CollectedHeap::full_gc_dump(GCTimer* timer, bool before) {
+  if ((HeapDumpBeforeFullGC && before) || (HeapDumpAfterFullGC && !before)) {
     GCIdMarkAndRestore gc_id_mark;
-    FormatBuffer<> title("Heap Dump (%s full gc)", when);
+    FormatBuffer<> title("Heap Dump (%s full gc)", before ? "before" : "after");
     GCTraceTime(Info, gc) tm(title.buffer(), timer);
     HeapDumper::dump_heap();
   }
@@ -582,7 +582,8 @@
   if (log.is_trace()) {
     ResourceMark rm;
     GCIdMarkAndRestore gc_id_mark;
-    FormatBuffer<> title("Class Histogram (%s full gc)", when);
+    FormatBuffer<> title("Class Histogram (%s full gc)",
+                         before ? "before" : "after");
     GCTraceTime(Trace, gc, classhisto) tm(title.buffer(), timer);
     VM_GC_HeapInspection inspector(log.trace_stream(), false /* ! full gc */);
     inspector.doit();
@@ -590,11 +591,11 @@
 }
 
 void CollectedHeap::pre_full_gc_dump(GCTimer* timer) {
-  full_gc_dump(timer, "before");
+  full_gc_dump(timer, true);
 }
 
 void CollectedHeap::post_full_gc_dump(GCTimer* timer) {
-  full_gc_dump(timer, "after");
+  full_gc_dump(timer, false);
 }
 
 void CollectedHeap::initialize_reserved_region(HeapWord *start, HeapWord *end) {
--- a/hotspot/src/share/vm/gc/shared/collectedHeap.hpp	Tue Feb 02 22:12:17 2016 -0500
+++ b/hotspot/src/share/vm/gc/shared/collectedHeap.hpp	Wed Feb 03 14:15:57 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -525,7 +525,7 @@
 
   // Generate any dumps preceding or following a full gc
  private:
-  void full_gc_dump(GCTimer* timer, const char* when);
+  void full_gc_dump(GCTimer* timer, bool before);
  public:
   void pre_full_gc_dump(GCTimer* timer);
   void post_full_gc_dump(GCTimer* timer);