changeset 46:affbc00b3f73

Bug 2452: JVM may crash when CMS GC occurs frequently. reviewed-by: ShinTak
author Yasumasa Suenaga <yasuenag@gmail.com>
date Fri, 19 Jun 2015 22:11:39 +0900
parents 34d299cf5596
children 52506cc0986b
files agent/ChangeLog agent/src/snapShotMain.cpp
diffstat 2 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/agent/ChangeLog	Thu May 28 17:15:44 2015 +0900
+++ b/agent/ChangeLog	Fri Jun 19 22:11:39 2015 +0900
@@ -1,3 +1,7 @@
+2015-06-19 Yasumasa Suenaga  <yasuenag@gmail.com>
+
+	* Bug 2452: JVM may crash when CMS GC occurs frequently.
+
 2015-05-28 KUBOTA Yuji  <kubota.yuji@lab.ntt.co.jp>
 
 	* Bump to 1.1.3
--- a/agent/src/snapShotMain.cpp	Thu May 28 17:15:44 2015 +0900
+++ b/agent/src/snapShotMain.cpp	Fri Jun 19 22:11:39 2015 +0900
@@ -1,7 +1,7 @@
 /*!
  * \file snapShotMain.cpp
  * \brief This file is used to take snapshot.
- * Copyright (C) 2011-2014 Nippon Telegraph and Telephone Corporation
+ * Copyright (C) 2011-2015 Nippon Telegraph and Telephone Corporation
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -661,8 +661,18 @@
  */
 void TakeSnapShot(jvmtiEnv *jvmti, JNIEnv *env, TInvokeCause cause) {
 
-    if(useCMS && (*CMS_collectorState > CMS_IDLING)){
+    /*
+     * Initial Mark is 1st phase in CMS.
+     * So we can process the SnapShot in SnapShot queue.
+     */
+    if(useCMS && (*CMS_collectorState > CMS_INITIALMARKING)){
       PRINT_WARN_MSG("CMS GC is working. Skip to take a SnapShot.");
+      TSnapShotContainer *snapshot = popSnapShotQueue();
+
+      if(likely(snapshot != NULL)){
+        TSnapShotContainer::releaseInstance(snapshot);
+      }
+
       return;
     }