Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/share/gc/AllMemoryObject.java
41161 views
1
/*
2
* Copyright (c) 2005, 2018, 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
package nsk.share.gc;
25
26
import java.io.PrintStream;
27
28
/**
29
* An object that occupies approximately given number of bytes in memory
30
* and also records number of allocated instances.
31
*/
32
public class AllMemoryObject extends MemoryObject {
33
private static int allocatedCount;
34
35
public AllMemoryObject(int size) {
36
super(size);
37
synchronized (AllMemoryObject.class) {
38
++allocatedCount;
39
}
40
}
41
42
/**
43
* Returns the number of allocated FinMemoryObjects.
44
*/
45
public static int getAllocatedCount() {
46
return allocatedCount;
47
}
48
49
public static void dumpStatistics(PrintStream out) {
50
out.println("Object count: " + getAllocatedCount());
51
}
52
53
public static void dumpStatistics() {
54
dumpStatistics(System.out);
55
}
56
}
57
58