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

Alexander Zuev kizune at openjdk.org
Mon Mar 3 17:43:53 UTC 2025


On Mon, 3 Mar 2025 17:04:52 GMT, Sergey Bylokhov <serb 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
>
> src/java.desktop/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java line 93:
> 
>> 91:             }
>> 92: 
>> 93:             long maximumHeapSize = Runtime.getRuntime().maxMemory() -
> 
> The test program does not contain any "real" large data, so it should not run into an OutOfMemoryError from the start.
> 
> Note that after the current patch, the code may still allocate a huge chunk of memory on large systems just by processing a small soundbank which is not good.

Well, it does contain a valid MIDI sequence that produces 1.9GB sound file - you can try to render it with any MIDI sequencer and will get the same result - the uncompressed WAV file generated with Apple GarageBand is about 2.1GB. That's just how MIDI work.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23814#discussion_r1977921357


More information about the client-libs-dev mailing list