Skip to content
Open
12 changes: 10 additions & 2 deletions core/src/main/java/org/apache/spark/memory/MemoryConsumer.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ public void spill() throws IOException {
*
* This should be implemented by subclass.
*
* Note: In order to avoid possible deadlock, should not call acquireMemory() from spill().
* Note: In order to avoid possible deadlock, implementations must release memory synchronously
* on the calling thread and must not acquire task memory from spill(), either directly or from
* another thread.
*
* Note: today, this only frees Tungsten-managed pages.
*
Expand Down Expand Up @@ -115,7 +117,8 @@ public void freeArray(LongArray array) {
* @throws SparkOutOfMemoryError
*/
protected MemoryBlock allocatePage(long required) {
MemoryBlock page = taskMemoryManager.allocatePage(Math.max(pageSize, required), this);
MemoryBlock page =
taskMemoryManager.allocatePageWithMinimum(Math.max(pageSize, required), required, this);
if (page == null || page.size() < required) {
throwOom(page, required);
}
Expand All @@ -131,6 +134,11 @@ protected void freePage(MemoryBlock page) {
taskMemoryManager.freePage(page, this);
}

/** Returns whether this page came from a minimum retry after a partial allocation failed. */
protected boolean isPageAllocationFromMinimumRetry(MemoryBlock page) {
return taskMemoryManager.isPageAllocationFromMinimumRetry(page);
}

/**
* Allocates memory of `size`.
*/
Expand Down
Loading