RFR: 8350813: Rendering of bulky sound bank from MIDI sequence can cause OutOfMemoryError
Alexander Zuev
kizune at openjdk.org
Thu Feb 27 03:51:52 UTC 2025
On Thu, 27 Feb 2025 01:31:54 GMT, Alexander Zvegintsev <azvegint 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
>
> test/jdk/javax/sound/midi/BulkSoundBank/BulkSoundBank.java line 33:
>
>> 31: * @bug 8350813
>> 32: * @summary Rendering of bulky sound bank from MIDI sequence can cause OutOfMemoryError.
>> 33: * @run main/othervm -Xmx1g BulkSoundBank
>
> The test can still throw OOME with `@run main/othervm -Xmx2g BulkSoundBank` after the fix. (Tested on Ubuntu 22.04)
>
> So it looks like the condition when we throw the `InvalidMidiDataException` should be tuned.
We can not predict OOME reliably - if size of the rendered data is 99% of the remaining heap and the file i/o or background task takes more than 2% of it - the memory will eventually end, there always will be corner cases no matter what treshold we choose. In the end rendering such a huge bank will take minutes and background task might consume more memory at the time. The code here stops OOME when we know for sure we will not have enough resources and lowering the amount might stop the legitimate use case from working.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23814#discussion_r1972788944
More information about the client-libs-dev
mailing list