RFR: 8350813: Rendering of bulky sound bank from MIDI sequence can cause OutOfMemoryError [v4]

Aleksey Shipilev shade at openjdk.org
Tue Mar 18 17:40:09 UTC 2025


On Wed, 5 Mar 2025 21:34:09 GMT, Alexander Zuev <kizune at openjdk.org> wrote:

>> - Check that the calculated audio data size does not exceed available heap memory before committing to the rendering
>> - Add a test case
>
> Alexander Zuev has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Merge branch 'JDK-8350813' of https://github.com/azuev-java/jdk into JDK-8350813
>  - Add a treshold of 90% to avoid OOME because of the additional buffers needed to process sound bank.

I emphasize the problem is with relying on `freeMemory`. That thing is not trustworthy to make the call you want to make. Only GC knows how much memory there is _actually free_, and it often knows only after attempting a GC cycle. If you want to get some headroom for both sound bank allocation and the subsequent rendering, then maybe the limit should be `maxMemory / <const>`, where divisor is some small integer. But `freeMemory` should not be in the equation if you want reliability, AFAIU.

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

PR Comment: https://git.openjdk.org/jdk/pull/23814#issuecomment-2734159467


More information about the client-libs-dev mailing list