RFR: 8275720: CommonComponentAccessibility.createWithParent isWrapped causes mem leak

Victor Dyakov vdyakov at openjdk.java.net
Fri Oct 22 18:05:11 UTC 2021


On Fri, 22 Oct 2021 16:02:32 GMT, Anton Tarasov <ant at openjdk.org> wrote:

> This is a reimplementation of the `isWrapped` logic in the method:
> 
> `+[CommonComponentAccessibility createWithParent:accessible:role:index:withEnv:withView:isWrapped:]`
> 
> The `isWrapped` arg was used to create an a11y element which is wrapped into an object that does not have direct peer in Java (like `ListRowAccessibility`, `TableRowAccessibility`). The problem is that such objects leak, because when the wrapped element is created (`isWrapped == YES`), the native pointer to the element is rewritten in the associated java peer (the `accessible` arg) and the element object is then released via the `CFRetainedResource` mechanism. However the wrapping object (`ListRowAccessibility`, `TableRowAccessibility`) is never released.
> 
> This fix proposes a dedicated class for creating such paired objects, where a wrapper object releases its wrapped child when the deallocation is triggered by garbage collecting the associated java peer.

@azuev-java @pankaj-bansal please review

-------------

PR: https://git.openjdk.java.net/jdk/pull/6081



More information about the client-libs-dev mailing list