Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/lang/management/MemoryMXBean/LowMemoryTest2.sh
41155 views
1
#
2
# Copyright (c) 2004, 2019, 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
#
23
24
#
25
# @test
26
# @bug 4982128
27
# @summary Test low memory detection of non-heap memory pool
28
#
29
# @requires vm.gc=="null"
30
#
31
# @run build LowMemoryTest2 MemoryUtil
32
# @run shell/timeout=600 LowMemoryTest2.sh
33
#
34
35
if [ ! -z "${TESTJAVA}" ] ; then
36
JAVA=${TESTJAVA}/bin/java
37
CLASSPATH=${TESTCLASSES}
38
export CLASSPATH
39
else
40
echo "--Error: TESTJAVA must be defined as the pathname of a jdk to test."
41
exit 1
42
fi
43
44
# Test execution
45
46
failures=0
47
48
go() {
49
echo ''
50
sh -xc "$JAVA $TESTVMOPTS $*" 2>&1
51
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
52
}
53
54
# Run test with each GC configuration
55
#
56
# Notes: To ensure that metaspace fills up we disable class unloading.
57
# Also we set the max metaspace to 16MB/32MB - otherwise the test takes too
58
# long to run. The 32MB setting is required for running with CDS archive.
59
60
go -noclassgc -XX:MaxMetaspaceSize=32m -XX:+UseSerialGC LowMemoryTest2
61
go -noclassgc -XX:MaxMetaspaceSize=32m -XX:+UseParallelGC LowMemoryTest2
62
63
# Test class metaspace - might hit MaxMetaspaceSize instead if
64
# UseCompressedClassPointers is off or if 32 bit.
65
#
66
# (note: This is very shaky and that shakiness exposes a problem with MemoryMXBean:
67
#
68
# MemoryMXBean defines "used" "committed" and "max" (see java/lang/management/MemoryUsage.java)
69
# This abstraction misses a definition for "address space exhausted" which with the new Metaspace (jep387)
70
# can happen before committed/used hits any trigger. We now commit only on demand and therefore class loaders
71
# can sit atop of uncommitted address space, denying new loaders address space. In the old Metaspace,
72
# we would have committed the space right away and therefore the MemoryMXBean "committed" trigger
73
# would have fired. In the new Metaspace, we don't commit, so the MemoryMXBean does not fire.
74
go -noclassgc -XX:MaxMetaspaceSize=16m -XX:CompressedClassSpaceSize=4m LowMemoryTest2
75
76
echo ''
77
if [ $failures -gt 0 ];
78
then echo "$failures test(s) failed";
79
else echo "All test(s) passed"; fi
80
exit $failures
81
82