Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,19 @@ public void testForceCopyOfBigCellInto() {

private Thread getChunkQueueTestThread(final MemStoreLABImpl mslab, String threadName,
ExtendedCell cellToCopyInto) {
// Reserve 20% of max heap as safety margin to prevent OOM on fast hardware where threads can
// allocate many GB of chunks within the 1-second test window.
final long maxMemory = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax();
final long memoryLimit = (long) (maxMemory * 0.8);
Thread thread = new Thread() {
volatile boolean stopped = false;

@Override
public void run() {
while (!stopped) {
if (ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed() > memoryLimit) {
break;
}
// keep triggering chunk retirement
mslab.copyCellInto(cellToCopyInto);
}
Expand Down