@@ -119,13 +119,13 @@ private[memory] class StorageMemoryPool(lock: Object) extends MemoryPool(lock) w
119119 }
120120
121121 /**
122- * Try to shrink the size of this storage memory pool by `spaceToFree` bytes. Return the number
123- * of bytes removed from the pool's capacity.
122+ * Free space to shrink the size of this storage memory pool by `spaceToFree` bytes.
123+ * Note: this method doesn't actually reduce the pool size but relies on the caller to do so.
124+ *
125+ * @return number of bytes to be removed from the pool's capacity.
124126 */
125- def shrinkPoolToFreeSpace (spaceToFree : Long ): Long = lock.synchronized {
126- // First, shrink the pool by reclaiming free memory:
127+ def freeSpaceToShrinkPool (spaceToFree : Long ): Long = lock.synchronized {
127128 val spaceFreedByReleasingUnusedMemory = math.min(spaceToFree, memoryFree)
128- decrementPoolSize(spaceFreedByReleasingUnusedMemory)
129129 val remainingSpaceToFree = spaceToFree - spaceFreedByReleasingUnusedMemory
130130 if (remainingSpaceToFree > 0 ) {
131131 // If reclaiming free memory did not adequately shrink the pool, begin evicting blocks:
@@ -134,7 +134,6 @@ private[memory] class StorageMemoryPool(lock: Object) extends MemoryPool(lock) w
134134 val spaceFreedByEviction = evictedBlocks.map(_._2.memSize).sum
135135 // When a block is released, BlockManager.dropFromMemory() calls releaseMemory(), so we do
136136 // not need to decrement _memoryUsed here. However, we do need to decrement the pool size.
137- decrementPoolSize(spaceFreedByEviction)
138137 spaceFreedByReleasingUnusedMemory + spaceFreedByEviction
139138 } else {
140139 spaceFreedByReleasingUnusedMemory
0 commit comments