2540N/A# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 2540N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2540N/A# This code is free software; you can redistribute it and/or modify it 2540N/A# under the terms of the GNU General Public License version 2 only, as 2540N/A# published by the Free Software Foundation. 2540N/A# This code is distributed in the hope that it will be useful, but WITHOUT 2540N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2540N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2540N/A# version 2 for more details (a copy is included in the LICENSE file that 2540N/A# You should have received a copy of the GNU General Public License version 2540N/A# 2 along with this work; if not, write to the Free Software Foundation, 2540N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2540N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2540N/A# @summary Check for WeakReference leak in Logger objects 2540N/A# @author Daniel D. Daugherty 2617N/A# @build SimpleApplication ShutdownSimpleApplication 2617N/A# The timeout is: 2 minutes for infrastructure and 2 minutes for the test 2540N/A# see if this version of jmap supports the '-histo:live' option 2622N/A # usage message doesn't show ':live' option 2622N/A # If SA isn't present, then jmap gives a different usage message 2622N/A # that doesn't show the ':live' option. However, that's a bug that 2622N/A # is covered by 6971851 so we try using the option just to be sure. 2622N/A # For some reason, this problem has only been seen on OpenJDK6 on 2622N/A # Note: Don't copy this code to try probing process 0 on Linux; it 2622N/A # will kill the process group in strange ways. 2622N/A # Usage message generated so flag the problem. 2622N/A # No usage message so clear the flag. 2622N/A echo "ERROR: cannot work reliably. Aborting!" 2617N/A # see if the target process has finished its run and bail if it has 2540N/A # Output format for 'jmap -histo' in JDK1.5.0: 2540N/A # <#bytes> <#instances> <class_name> 2540N/A # Output format for 'jmap -histo:live': 2540N/A # <num>: <#instances> <#bytes> <class_name> 2617N/A # There are intermittent jmap failures; see 6498448. 2617N/A # So far the following have been observed in a jmap call 2617N/A # that was not in a race with target process termination: 2617N/A # (Solaris specific, 2nd sample) 2617N/A # <pid>: Unable to open door: target process not responding or HotSpot VM not loaded 2617N/A # The -F option can be used when the target process is not responding 2617N/A # (on Solaris so far, 1st sample) 2617N/A # loop count hasn't changed 2617N/A # loop count has changed so remember it 2617N/A # This is '-ge' because we have the original attempt plus 2617N/A # MAX_JMAP_TRY_CNT - 1 retries. 2617N/A "without making any progress." 2540N/A echo "FAIL: jmap is unable to take any samples." >&
2 2617N/A # short delay and try again 2617N/A # Note: sleep 1 didn't help with "<pid>: Permission denied" 2540N/A # strip leading whitespace; does nothing in JDK1.5.0 2617N/A s/^'"${PATTERN_WS}${PATTERN_WS}"'*// 2540N/A # strip <#bytes> in JDK1.5.0; does nothing otherwise 2617N/A s/^[1-9][0-9]*'"${PATTERN_WS}${PATTERN_WS}"'*// 2540N/A # strip <num>: field; does nothing in JDK1.5.0 2617N/A s/^[1-9][0-9]*:'"${PATTERN_WS}${PATTERN_WS}"'*// 2540N/A echo "INFO: instance count is unexpectedly empty" 2540N/A echo "INFO: on the first iteration so no sample was found." 2540N/A echo "INFO: There is likely a problem with the sed filter." 2540N/A echo "INFO: start of jmap output:" 2540N/A echo "INFO: end of jmap output." 2540N/A echo "FAIL: cannot find the instance count value." >&
2 2617N/A # actually decreasing or the same 2617N/A # For these particular WeakReference leaks, the count was 2617N/A # always observed to be increasing so if we get a decreasing 2617N/A # or the same count, then the leaks are fixed in the bits 2617N/A echo "INFO: finishing early due to non-increasing instance count." 2617N/A echo "FAIL: jmap is unable to take any samples." >&
2 2540N/A echo "INFO: is always increasing." 2540N/A echo "FAIL: This indicates that there is a memory leak." >&
2 2617N/Aecho "INFO: is not always increasing." 2540N/Aecho "PASS: This indicates that there is not a memory leak."