Maximal file size for AudioTrack?


I have a 30 mb .wav music file but it can't be loaded!

I've figured out in the OpenALSystem is the limit:

private static final long MAX_MEMORY = 16 * 1024 * 1024; // 16 MB


Exception in thread "Thread-5" java.lang.OutOfMemoryError: Java heap space
   at java.util.Arrays.copyOf(

Why is the max memory 16 mb?

i dont think 16 mb is the max size.

try to increase the java heap space with a jvm parameter -Xmx<size>

I have not done this myself… but it should also be possible to stream audio, so that less of it is in the memory at the same time…

Yeah, I was wrong to say there is a file limit.

There is actually no size limit for audio track files. I can now load everything.

After I tuned my VM in Eclipse for more memory allocation everything works.

I put this argument in the run configuration like said in other posts:


I haven't tried audio streaming yet, but I'm going to as soon as my network works.

Any code snippset to show audio streaming would be a good start nevertheless ;)

I do not have any examples ready for this, but I think it is as simple as passing 'true' to the stream parameter when you do AudioSystem.getSystem().createAudioTrack.