author | dcubed |
Mon, 12 Jul 2010 14:19:44 -0700 | |
changeset 6006 | 91227f996b53 |
parent 5964 | 0496aa46ae9f |
child 6120 | 4979c5d548f8 |
permissions | -rw-r--r-- |
5964
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
1 |
# |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
2 |
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
3 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
4 |
# |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
5 |
# This code is free software; you can redistribute it and/or modify it |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
6 |
# under the terms of the GNU General Public License version 2 only, as |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
7 |
# published by the Free Software Foundation. |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
8 |
# |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
9 |
# This code is distributed in the hope that it will be useful, but WITHOUT |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
10 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
11 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
12 |
# version 2 for more details (a copy is included in the LICENSE file that |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
13 |
# accompanied this code). |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
14 |
# |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
15 |
# You should have received a copy of the GNU General Public License version |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
16 |
# 2 along with this work; if not, write to the Free Software Foundation, |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
17 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
18 |
# |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
19 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
20 |
# or visit www.oracle.com if you need additional information or have any |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
21 |
# questions. |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
22 |
# |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
23 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
24 |
# @test |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
25 |
# @bug 6942989 |
6006
91227f996b53
6968401: 3/3 disable tests added by 6942989 until 6964018 is fixed
dcubed
parents:
5964
diff
changeset
|
26 |
# @ignore until 6964018 is fixed |
5964
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
27 |
# @summary Check for WeakReference leak in anonymous Logger objects |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
28 |
# @author Daniel D. Daugherty |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
29 |
# |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
30 |
# @run build AnonLoggerWeakRefLeak |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
31 |
# @run shell/timeout=180 AnonLoggerWeakRefLeak.sh |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
32 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
33 |
# The timeout is: 2 minutes for infrastructure and 1 minute for the test |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
34 |
# |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
35 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
36 |
if [ "${TESTJAVA}" = "" ] |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
37 |
then |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
38 |
echo "TESTJAVA not set. Test cannot execute. Failed." |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
39 |
exit 1 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
40 |
fi |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
41 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
42 |
if [ "${TESTSRC}" = "" ] |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
43 |
then |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
44 |
echo "TESTSRC not set. Test cannot execute. Failed." |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
45 |
exit 1 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
46 |
fi |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
47 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
48 |
if [ "${TESTCLASSES}" = "" ] |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
49 |
then |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
50 |
echo "TESTCLASSES not set. Test cannot execute. Failed." |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
51 |
exit 1 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
52 |
fi |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
53 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
54 |
JAVA="${TESTJAVA}"/bin/java |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
55 |
JMAP="${TESTJAVA}"/bin/jmap |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
56 |
JPS="${TESTJAVA}"/bin/jps |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
57 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
58 |
set -eu |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
59 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
60 |
TEST_NAME="AnonLoggerWeakRefLeak" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
61 |
TARGET_CLASS="java\.lang\.ref\.WeakReference" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
62 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
63 |
is_cygwin=false |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
64 |
is_mks=false |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
65 |
is_windows=false |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
66 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
67 |
case `uname -s` in |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
68 |
CYGWIN*) |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
69 |
is_cygwin=true |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
70 |
is_windows=true |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
71 |
;; |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
72 |
Windows_*) |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
73 |
is_mks=true |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
74 |
is_windows=true |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
75 |
;; |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
76 |
*) |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
77 |
;; |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
78 |
esac |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
79 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
80 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
81 |
# wrapper for grep |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
82 |
# |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
83 |
grep_cmd() { |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
84 |
set +e |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
85 |
if $is_windows; then |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
86 |
# need dos2unix to get rid of CTRL-M chars from java output |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
87 |
dos2unix | grep "$@" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
88 |
status="$?" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
89 |
else |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
90 |
grep "$@" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
91 |
status="$?" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
92 |
fi |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
93 |
set -e |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
94 |
} |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
95 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
96 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
97 |
# MAIN begins here |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
98 |
# |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
99 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
100 |
seconds= |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
101 |
if [ "$#" -gt 0 ]; then |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
102 |
seconds="$1" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
103 |
fi |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
104 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
105 |
# see if this version of jmap supports the '-histo:live' option |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
106 |
jmap_option="-histo:live" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
107 |
set +e |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
108 |
"${JMAP}" "$jmap_option" 0 > "$TEST_NAME.jmap" 2>&1 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
109 |
grep '^Usage: ' "$TEST_NAME.jmap" > /dev/null 2>&1 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
110 |
status="$?" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
111 |
set -e |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
112 |
if [ "$status" = 0 ]; then |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
113 |
echo "INFO: switching jmap option from '$jmap_option'\c" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
114 |
jmap_option="-histo" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
115 |
echo " to '$jmap_option'." |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
116 |
fi |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
117 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
118 |
"${JAVA}" ${TESTVMOPTS} -classpath "${TESTCLASSES}" \ |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
119 |
"$TEST_NAME" $seconds > "$TEST_NAME.log" 2>&1 & |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
120 |
test_pid="$!" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
121 |
echo "INFO: starting $TEST_NAME as pid = $test_pid" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
122 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
123 |
# wait for test program to get going |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
124 |
count=0 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
125 |
while [ "$count" -lt 30 ]; do |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
126 |
sleep 2 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
127 |
grep_cmd '^INFO: call count = 0$' < "$TEST_NAME.log" > /dev/null 2>&1 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
128 |
if [ "$status" = 0 ]; then |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
129 |
break |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
130 |
fi |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
131 |
count=`expr $count + 1` |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
132 |
done |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
133 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
134 |
if [ "$count" -ge 30 ]; then |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
135 |
echo "ERROR: $TEST_NAME failed to get going." >&2 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
136 |
echo "INFO: killing $test_pid" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
137 |
kill "$test_pid" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
138 |
exit 1 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
139 |
elif [ "$count" -gt 1 ]; then |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
140 |
echo "INFO: $TEST_NAME took $count loops to start." |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
141 |
fi |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
142 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
143 |
if $is_cygwin; then |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
144 |
# We need the Windows pid for jmap and not the Cygwin pid. |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
145 |
# Note: '\t' works on Cygwin, but doesn't seem to work on Solaris. |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
146 |
jmap_pid=`"${JPS}"| grep_cmd "[ \t]$TEST_NAME$" | sed 's/[ \t].*//'` |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
147 |
if [ -z "$jmap_pid" ]; then |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
148 |
echo "FAIL: jps could not map Cygwin pid to Windows pid." >&2 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
149 |
echo "INFO: killing $test_pid" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
150 |
kill "$test_pid" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
151 |
exit 2 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
152 |
fi |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
153 |
echo "INFO: pid = $test_pid maps to Windows pid = $jmap_pid" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
154 |
else |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
155 |
jmap_pid="$test_pid" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
156 |
fi |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
157 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
158 |
decreasing_cnt=0 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
159 |
increasing_cnt=0 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
160 |
loop_cnt=0 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
161 |
prev_instance_cnt=0 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
162 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
163 |
while true; do |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
164 |
# Output format for 'jmap -histo' in JDK1.5.0: |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
165 |
# |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
166 |
# <#bytes> <#instances> <class_name> |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
167 |
# |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
168 |
# Output format for 'jmap -histo:live': |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
169 |
# |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
170 |
# <num>: <#instances> <#bytes> <class_name> |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
171 |
# |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
172 |
set +e |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
173 |
"${JMAP}" "$jmap_option" "$jmap_pid" > "$TEST_NAME.jmap" 2>&1 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
174 |
status="$?" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
175 |
set -e |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
176 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
177 |
if [ "$status" != 0 ]; then |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
178 |
echo "INFO: jmap exited with exit code = $status" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
179 |
if [ "$loop_cnt" = 0 ]; then |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
180 |
echo "INFO: on the first iteration so no samples were taken." |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
181 |
echo "INFO: start of jmap output:" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
182 |
cat "$TEST_NAME.jmap" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
183 |
echo "INFO: end of jmap output." |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
184 |
echo "FAIL: jmap is unable to take any samples." >&2 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
185 |
echo "INFO: killing $test_pid" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
186 |
kill "$test_pid" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
187 |
exit 2 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
188 |
fi |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
189 |
echo "INFO: The likely reason is that $TEST_NAME has finished running." |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
190 |
break |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
191 |
fi |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
192 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
193 |
instance_cnt=`grep_cmd "[ ]$TARGET_CLASS$" \ |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
194 |
< "$TEST_NAME.jmap" \ |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
195 |
| sed ' |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
196 |
# strip leading whitespace; does nothing in JDK1.5.0 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
197 |
s/^[ ][ ]*// |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
198 |
# strip <#bytes> in JDK1.5.0; does nothing otherwise |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
199 |
s/^[1-9][0-9]*[ ][ ]*// |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
200 |
# strip <num>: field; does nothing in JDK1.5.0 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
201 |
s/^[1-9][0-9]*:[ ][ ]*// |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
202 |
# strip <class_name> field |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
203 |
s/[ ].*// |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
204 |
'` |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
205 |
if [ -z "$instance_cnt" ]; then |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
206 |
echo "INFO: instance count is unexpectedly empty" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
207 |
if [ "$loop_cnt" = 0 ]; then |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
208 |
echo "INFO: on the first iteration so no sample was found." |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
209 |
echo "INFO: There is likely a problem with the sed filter." |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
210 |
echo "INFO: start of jmap output:" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
211 |
cat "$TEST_NAME.jmap" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
212 |
echo "INFO: end of jmap output." |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
213 |
echo "FAIL: cannot find the instance count value." >&2 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
214 |
echo "INFO: killing $test_pid" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
215 |
kill "$test_pid" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
216 |
exit 2 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
217 |
fi |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
218 |
else |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
219 |
echo "INFO: instance_cnt = $instance_cnt" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
220 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
221 |
if [ "$instance_cnt" -gt "$prev_instance_cnt" ]; then |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
222 |
increasing_cnt=`expr $increasing_cnt + 1` |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
223 |
else |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
224 |
decreasing_cnt=`expr $decreasing_cnt + 1` |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
225 |
fi |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
226 |
prev_instance_cnt="$instance_cnt" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
227 |
fi |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
228 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
229 |
# delay between samples |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
230 |
sleep 5 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
231 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
232 |
loop_cnt=`expr $loop_cnt + 1` |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
233 |
done |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
234 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
235 |
echo "INFO: increasing_cnt = $increasing_cnt" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
236 |
echo "INFO: decreasing_cnt = $decreasing_cnt" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
237 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
238 |
echo "INFO: The instance count of" `eval echo $TARGET_CLASS` "objects" |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
239 |
if [ "$decreasing_cnt" = 0 ]; then |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
240 |
echo "INFO: is always increasing." |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
241 |
echo "FAIL: This indicates that there is a memory leak." >&2 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
242 |
exit 2 |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
243 |
fi |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
244 |
|
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
245 |
echo "INFO: is both increasing and decreasing." |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
246 |
echo "PASS: This indicates that there is not a memory leak." |
0496aa46ae9f
6942989: 2/2 Memory leak of java.lang.ref.WeakReference objects
dcubed
parents:
diff
changeset
|
247 |
exit 0 |