[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-2d-dev
Subject:    Re: RFR: 6507038: Memory Leak in JTree / BasicTreeUI [v3]
From:       Alexey Ivanov <aivanov () openjdk ! org>
Date:       2024-01-31 17:30:07
Message-ID: xURiwVq6qsqgnDLseDGMDvpevoU9rK8WCWwyD2ovUW0=.0d99df4f-b75c-483c-889f-3661f55f4366 () github ! com
[Download RAW message or body]

On Wed, 31 Jan 2024 05:35:44 GMT, Prasanta Sadhukhan <psadhukhan@openjdk.org> wrote:

> > It's simpler with `PhantomReference`. This type of reference does not allow \
> > getting its referent, and it's not needed in this case. When the referent of a \
> > reference is cleared by the GC, the reference is added into the associated \
> > reference queue. This is true for any type of `Reference`, but `PhantomReference` \
> > has to use a reference queue. 
> > Here's how to use them: \
> > https://github.com/aivanov-jdk/jdk/commit/b0da8b30fdcf03abffa663eb5ba42df1fe4a9971
> >  
> > I keep the references in a list. The size of the list is the number of live \
> > `JLabel` objects. On each iteration, I poll the reference queue and remove the \
> > _dead_ references from the list. 
> > https://github.com/openjdk/jdk/blob/b0da8b30fdcf03abffa663eb5ba42df1fe4a9971/test/jdk/javax/swing/plaf/basic/BasicTreeUI/TreeCellRendererLeakTest.java#L193-L201
> >  
> > If the number of removed references is zero, the test fails because objects are \
> > leaked. Otherwise, the test passes. This aligns with your latest changes. 
> > Your code also does the job. I'll approve it if you don't want to use \
> > `PhantomReference`.
> 
> Thanks for your "reference" on PhantomReference..Although my testcode is doing same \
> thing (which you acknowledged) no harm in trying new way (for me) for my future \
> reference so have updated the test to use PhantomReference.

Could you add me as contributor, please?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17458#discussion_r1473192053


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic