20
20
*
21
21
* <p>Mostly forked from Lucene tag releases/lucene-solr/8.5.1
22
22
*/
23
- public class RamUsageEstimator {
23
+ final class RamUsageEstimator {
24
24
/** One kilobyte bytes. */
25
- public static final long ONE_KB = 1024 ;
25
+ static final long ONE_KB = 1024 ;
26
26
27
27
/** One megabyte bytes. */
28
- public static final long ONE_MB = ONE_KB * ONE_KB ;
28
+ static final long ONE_MB = ONE_KB * ONE_KB ;
29
29
30
30
/** One gigabyte bytes. */
31
- public static final long ONE_GB = ONE_KB * ONE_MB ;
31
+ static final long ONE_GB = ONE_KB * ONE_MB ;
32
32
33
33
/** No instantiation. */
34
34
private RamUsageEstimator () {}
35
35
36
36
/** True, iff compressed references (oops) are enabled by this JVM */
37
- public static final boolean COMPRESSED_REFS_ENABLED ;
37
+ static final boolean COMPRESSED_REFS_ENABLED ;
38
38
39
39
/** Number of bytes this JVM uses to represent an object reference. */
40
- public static final int NUM_BYTES_OBJECT_REF ;
40
+ static final int NUM_BYTES_OBJECT_REF ;
41
41
42
42
/** Number of bytes to represent an object header (no fields, no alignments). */
43
- public static final int NUM_BYTES_OBJECT_HEADER ;
43
+ static final int NUM_BYTES_OBJECT_HEADER ;
44
44
45
45
/** Number of bytes to represent an array header (no content, but with alignments). */
46
- public static final int NUM_BYTES_ARRAY_HEADER ;
46
+ static final int NUM_BYTES_ARRAY_HEADER ;
47
47
48
48
/**
49
49
* A constant specifying the object alignment boundary inside the JVM. Objects will always take a
50
50
* full multiple of this constant, possibly wasting some space.
51
51
*/
52
- public static final int NUM_BYTES_OBJECT_ALIGNMENT ;
52
+ static final int NUM_BYTES_OBJECT_ALIGNMENT ;
53
53
54
54
/** Sizes of primitive classes. */
55
- public static final Map <Class <?>, Integer > primitiveSizes ;
55
+ static final Map <Class <?>, Integer > primitiveSizes ;
56
56
57
57
static {
58
58
Map <Class <?>, Integer > primitiveSizesMap = new IdentityHashMap <>();
@@ -141,7 +141,7 @@ private RamUsageEstimator() {}
141
141
}
142
142
143
143
/** Aligns an object size to be the next multiple of {@link #NUM_BYTES_OBJECT_ALIGNMENT}. */
144
- public static long alignObjectSize (long size ) {
144
+ static long alignObjectSize (long size ) {
145
145
size += (long ) NUM_BYTES_OBJECT_ALIGNMENT - 1L ;
146
146
return size - (size % NUM_BYTES_OBJECT_ALIGNMENT );
147
147
}
@@ -151,7 +151,7 @@ public static long alignObjectSize(long size) {
151
151
*
152
152
* @param usedSize Size that array is actually used
153
153
*/
154
- public static long shallowUsedSizeOfArray (Object array , int usedSize ) {
154
+ static long shallowUsedSizeOfArray (Object array , int usedSize ) {
155
155
long size = NUM_BYTES_ARRAY_HEADER ;
156
156
if (usedSize > 0 ) {
157
157
Class <?> arrayElementClazz = array .getClass ().getComponentType ();
@@ -165,7 +165,7 @@ public static long shallowUsedSizeOfArray(Object array, int usedSize) {
165
165
}
166
166
167
167
/** Return shallow size of any <code>array</code>. */
168
- public static long shallowSizeOfArray (Object array ) {
168
+ static long shallowSizeOfArray (Object array ) {
169
169
return shallowUsedSizeOfArray (array , Array .getLength (array ));
170
170
}
171
171
}
0 commit comments