what-the-bank/sources/com/kofax/kmc/kut/utilities/Sizeof.java

201 lines
6.3 KiB
Java

package com.kofax.kmc.kut.utilities;
import java.io.PrintStream;
/* loaded from: classes3.dex */
public class Sizeof {
private static SizeOfNewObject nT;
private static final Runtime nU = Runtime.getRuntime();
/* loaded from: classes3.dex */
public enum ObjectDataTypes {
DATA_TYPE_OBJECT_SHELL,
DATA_TYPE_OBJECT_REF,
DATA_TYPE_LONG_FIELD,
DATA_TYPE_INT_FIELD,
DATA_TYPE_SHORT_FIELD,
DATA_TYPE_CHAR_FIELD,
DATA_TYPE_BYTE_FIELD,
DATA_TYPE_BOOLEAN_FIELD,
DATA_TYPE_DOUBLE_FIELD,
DATA_TYPE_FLOAT_FIELD,
DATA_TYPE_APP_CREATED
}
/* loaded from: classes3.dex */
public interface SizeOfNewObject {
Object genNextNewObject();
}
private static Object e(int i) {
return nT.genNextNewObject();
}
public static int computeObjectSize(ObjectDataTypes objectDataTypes, int i) throws Exception {
int round;
Object obj;
synchronized (Sizeof.class) {
aH();
aJ();
Object[] objArr = new Object[i];
long j = 0;
for (int i2 = -1; i2 < i; i2++) {
switch (AnonymousClass1.nV[objectDataTypes.ordinal()]) {
case 1:
obj = new Object();
break;
case 2:
obj = new Object();
break;
case 3:
obj = new Long(i2);
break;
case 4:
obj = Integer.valueOf(i2);
break;
case 5:
obj = new Short((short) i2);
break;
case 6:
obj = new Character((char) i2);
break;
case 7:
obj = new Byte((byte) i2);
break;
case 8:
obj = Boolean.TRUE;
break;
case 9:
obj = new Double(i2);
break;
case 10:
obj = new Float(i2);
break;
case 11:
obj = e(i2);
break;
default:
throw new UnsupportedOperationException("computeObjectSize method: unsupported Object Data Type");
}
if (i2 >= 0) {
objArr[i2] = obj;
} else {
aH();
j = aJ();
}
}
aH();
long aJ = aJ();
long j2 = aJ - j;
round = Math.round(((float) j2) / i);
PrintStream printStream = System.out;
StringBuilder sb = new StringBuilder();
sb.append("'before' heap: ");
sb.append(j);
sb.append(", 'after' heap: ");
sb.append(aJ);
printStream.println(sb.toString());
PrintStream printStream2 = System.out;
StringBuilder sb2 = new StringBuilder();
sb2.append("heap delta: ");
sb2.append(j2);
sb2.append(", {");
sb2.append(objArr[0].getClass());
sb2.append("} size = ");
sb2.append(round);
sb2.append(" bytes");
printStream2.println(sb2.toString());
for (int i3 = 0; i3 < i; i3++) {
objArr[i3] = null;
}
}
return round;
}
/* renamed from: com.kofax.kmc.kut.utilities.Sizeof$1, reason: invalid class name */
/* loaded from: classes3.dex */
static /* synthetic */ class AnonymousClass1 {
static final int[] nV;
static {
int[] iArr = new int[ObjectDataTypes.values().length];
nV = iArr;
try {
iArr[ObjectDataTypes.DATA_TYPE_OBJECT_SHELL.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
nV[ObjectDataTypes.DATA_TYPE_OBJECT_REF.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
nV[ObjectDataTypes.DATA_TYPE_LONG_FIELD.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
nV[ObjectDataTypes.DATA_TYPE_INT_FIELD.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
nV[ObjectDataTypes.DATA_TYPE_SHORT_FIELD.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
nV[ObjectDataTypes.DATA_TYPE_CHAR_FIELD.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
try {
nV[ObjectDataTypes.DATA_TYPE_BYTE_FIELD.ordinal()] = 7;
} catch (NoSuchFieldError unused7) {
}
try {
nV[ObjectDataTypes.DATA_TYPE_BOOLEAN_FIELD.ordinal()] = 8;
} catch (NoSuchFieldError unused8) {
}
try {
nV[ObjectDataTypes.DATA_TYPE_DOUBLE_FIELD.ordinal()] = 9;
} catch (NoSuchFieldError unused9) {
}
try {
nV[ObjectDataTypes.DATA_TYPE_FLOAT_FIELD.ordinal()] = 10;
} catch (NoSuchFieldError unused10) {
}
try {
nV[ObjectDataTypes.DATA_TYPE_APP_CREATED.ordinal()] = 11;
} catch (NoSuchFieldError unused11) {
}
}
}
private static void aH() throws Exception {
for (int i = 0; i < 4; i++) {
aI();
}
}
private static void aI() throws Exception {
long aJ = aJ();
long j = Long.MAX_VALUE;
int i = 0;
while (aJ < j && i < 500) {
Runtime runtime = nU;
runtime.runFinalization();
runtime.gc();
Thread.yield();
i++;
long j2 = aJ;
aJ = aJ();
j = j2;
}
}
private static long aJ() {
Runtime runtime = nU;
return runtime.totalMemory() - runtime.freeMemory();
}
public static void registerNewObjectListener(SizeOfNewObject sizeOfNewObject) {
nT = sizeOfNewObject;
}
}