facebook/presto — pull request #1318 by miniway (2014-05-20 00:37:16+00:00)
Title: DriverContext.getOperatorPreAllocatedMemory uses parent context's getOperatorPreAllocatedMemory

I might be wrong and might not understand internal correctly, but if pipelineContext.getMaxMemorySize() is used for DriverContext.getOperatorPreAllocatedMemory, a driver might consumer more memory than expected.

At the MemoryManager, memorySize seems to be easily negative value.

// remove the pre-allocated memory from this size
memorySize -= operatorContext.getOperatorPreAllocatedMemory().toBytes();

long delta = memorySize - currentMemoryReservation;
if (delta <= 0) {
return true;
}