[ 
https://issues.apache.org/jira/browse/FLINK-21753?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Xintong Song reassigned FLINK-21753:
------------------------------------

    Assignee: Kezhu Wang

> Cycle references between memory manager and gc cleaner action
> -------------------------------------------------------------
>
>                 Key: FLINK-21753
>                 URL: https://issues.apache.org/jira/browse/FLINK-21753
>             Project: Flink
>          Issue Type: Bug
>          Components: Runtime / Task
>    Affects Versions: 1.10.3, 1.11.3, 1.12.2
>            Reporter: Kezhu Wang
>            Assignee: Kezhu Wang
>            Priority: Major
>
> {{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:
> {quote}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.
> {quote}
> See also FLINK-13985 FLINK-21419.
> I pushed [test 
> case|https://github.com/kezhuw/flink/commit/9a5d71d3a6be50611cf2f5c65c39f51353167306]
>  in my repository after FLINK-21419 (which merged in 1.12.2 but not before) 
> for evaluation.
> cc [~azagrebin] [~xintongsong] [~trohrmann] [~ykt836] [~nicholasjiang] 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to