Hi Sergey,
The fix looks correct to me.
On 9/14/2016 6:35 PM, Sergey Bylokhov wrote:
Hello.
Please review the small fix for jdk9. Note that I plan to backport it
to jdk8:
That would be really good, thanks!
Regards,
Anton.
NSApplicationAWT class have a special method which posts event to the
native queue. This event is used to execute the block of code which
contains CFRelease for some native resource. It was implemented in
this way (instead of simple "performOnmMainThread") because we should
filter this event when the nested native loop is active. The problem
is that this method overretain the block. [block copy] copy the block
from the stack and retain it(or just retain if the block is in memory
already), and since we retain it again we get a memory leak, because
we release it only once in NSApplicationAWT.sendEvent(). The leak is
quite small but the code can be executed lots of time which cause
allocation of unreasonable amount of memory. There is no test since
the leak is native, and it will be necessary to spend lots of time to
fill the whole native memory and swap.
The bug was found when I worked on 'other fix', and some other memory
leaks will be fixed separately in 'other fix'.
Bug: https://bugs.openjdk.java.net/browse/JDK-8165717
Patch can be found at: http://cr.openjdk.java.net/~serb/8165717/webrev.00