Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.10.3, 1.11.3, 1.12.2
Description
MemoryManager.allocatePages uses this::releasePage as cleanup action in MemorySegmentFactory.allocateOffHeapUnsafeMemory. The cleanup function is used as gc cleaner action there. This creates a cycle referencing between memory manager and gc cleaner if allocated memory segment is not MemoryManager.release in time. Symptoms should be different based on versions:
- Before 1.12.2: memory will not be reclaimed until gc after MemoryManager.release
- * 1.12.2: memory will not be reclaimed until MemorySegment.free or gc after MemoryManager.release
I quotes javadoc from jdk java.lang.ref.Cleaner here for references:
The cleaning action is invoked only after the associated object becomes phantom reachable, so it is important that the object implementing the cleaning action does not hold references to the object. In this example, a static class encapsulates the cleaning state and action. An "inner" class, anonymous or not, must not be used because it implicitly contains a reference to the outer instance, preventing it from becoming phantom reachable. The choice of a new cleaner or sharing an existing cleaner is determined by the use case.
See also FLINK-13985 FLINK-21419.
I pushed test case in my repository after FLINK-21419 (which merged in 1.12.2 but not before) for evaluation.
Attachments
Issue Links
- links to