long address = unsafe.allocateMemory(1);
assertNotEquals(address, 0L);
// Make sure we reallocate correctly
unsafe.putByte(address, Byte.MAX_VALUE);
address = unsafe.reallocateMemory(address, 2);
assertNotEquals(address, 0L);
assertEquals(unsafe.getByte(address), Byte.MAX_VALUE);
// Reallocating with a 0 size should return a null pointer
address = unsafe.reallocateMemory(address, 0);
assertEquals(address, 0L);
// Reallocating with a null pointer should result in a normal allocation
address = unsafe.reallocateMemory(0L, 1);
assertNotEquals(address, 0L);
unsafe.putByte(address, Byte.MAX_VALUE);
assertEquals(unsafe.getByte(address), Byte.MAX_VALUE);
// Make sure we can throw an OOME when we fail to reallocate due to OOM try {
unsafe.reallocateMemory(address, 100 * 1024 * 1024 * 8);
} catch (OutOfMemoryError e) { // Expected return;
} thrownew RuntimeException("Did not get expected OOM");
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.18 Sekunden
(vorverarbeitet am 2026-10-01)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.