There is some limit to the file size of multimedia files for use in CommCare
applications, which if surpassed will land you a "Out of memory error
java/lang/OutOfMemoryError".
The file size limit is somewhere between 411kb (works fine) and 644kb (out
of memory). A 411kb audio file corresponds to ~25 seconds of 128kbps mp3.
I know some of you have encountered this error before, so feel free to share
more details here if useful.
Yeah, the limits will vary per phone and the amount of memory made available
to the app. I'll see if we're doing something naive that might increase the
audio capacity, but other than that Drew's tricks should hopefully get you
to more like a minute of audio.
-Clayton
···
On Tue, Apr 19, 2011 at 8:59 AM, Drew Roos wrote:
also, using variable bit-rate encoding (VBR) and a quality encoder (i.e.,
LAME) can get you more bang for your buck... err, byte.
On Tue, Apr 19, 2011 at 5:23 PM, Drew Roos droos@dimagi.com wrote:
i also recently encountered this error. note to self: don't use wav files!
also, voice prompts can get by with a much lower bitrate. 64 kpbs mono
should be adequate.
There is some limit to the file size of multimedia files for use in
CommCare applications, which if surpassed will land you a "Out of memory
error java/lang/OutOfMemoryError". The file size limit is somewhere
between 411kb (works fine) and 644kb (out of memory). A 411kb audio file
corresponds to ~25 seconds of 128kbps mp3.
I know some of you have encountered this error before, so feel free to
share more details here if useful.
i also recently encountered this error. note to self: don't use wav files!
also, voice prompts can get by with a much lower bitrate. 64 kpbs mono
should be adequate.
···
On Tue, Apr 19, 2011 at 4:42 PM, Derek Treatman wrote:
Hello all,
There is some limit to the file size of multimedia files for use in
CommCare applications, which if surpassed will land you a "Out of memory
error java/lang/OutOfMemoryError". The file size limit is somewhere
between 411kb (works fine) and 644kb (out of memory). A 411kb audio file
corresponds to ~25 seconds of 128kbps mp3.
I know some of you have encountered this error before, so feel free to
share more details here if useful.
There is some limit to the file size of multimedia files for use in
CommCare applications, which if surpassed will land you a "Out of memory
error java/lang/OutOfMemoryError". The file size limit is somewhere
between 411kb (works fine) and 644kb (out of memory). A 411kb audio file
corresponds to ~25 seconds of 128kbps mp3.
I know some of you have encountered this error before, so feel free to
share more details here if useful.
also, playing multiple clips back to back could be an option for
circumventing the limit, but would require support in the app. why does j2me
hate streams?
···
On Tue, Apr 19, 2011 at 8:39 PM, Clayton Sims wrote:
Derek,
Yeah, the limits will vary per phone and the amount of memory made
available to the app. I'll see if we're doing something naive that might
increase the audio capacity, but other than that Drew's tricks should
hopefully get you to more like a minute of audio.
-Clayton
On Tue, Apr 19, 2011 at 8:59 AM, Drew Roos droos@dimagi.com wrote:
also, using variable bit-rate encoding (VBR) and a quality encoder (i.e.,
LAME) can get you more bang for your buck... err, byte.
On Tue, Apr 19, 2011 at 5:23 PM, Drew Roos droos@dimagi.com wrote:
i also recently encountered this error. note to self: don't use wav
files!
also, voice prompts can get by with a much lower bitrate. 64 kpbs mono
should be adequate.
There is some limit to the file size of multimedia files for use in
CommCare applications, which if surpassed will land you a "Out of
memory error java/lang/OutOfMemoryError". The file size limit is
somewhere between 411kb (works fine) and 644kb (out of memory). A 411kb
audio file corresponds to ~25 seconds of 128kbps mp3.
I know some of you have encountered this error before, so feel free to
share more details here if useful.
Hi all,
My application land me to this out of memory error at the end of
registration form and i am not using any audio in my app.
see attached registration form attached. Any Idea what could be causing
this?
I am using nokia C2.
···
On Tuesday, April 19, 2011 3:12:18 PM UTC+3, Derek Treatman wrote:
>
> Hello all,
>
> There is some limit to the file size of multimedia files for use in
> CommCare applications, which if surpassed will land you a "Out of memory
> error java/lang/OutOfMemoryError". The file size limit is somewhere
> between 411kb (works fine) and 644kb (out of memory). A 411kb audio file
> corresponds to ~25 seconds of 128kbps mp3.
>
> I know some of you have encountered this error before, so feel free to
> share more details here if useful.
>
> Cheers,
> Derek
>
We are actually steaming the audio when we play it, so I'm not sure why
there should be any inherent limit to the file size.
-Clayton
···
On Tue, Apr 19, 2011 at 12:32 PM, Drew Roos wrote:
also, playing multiple clips back to back could be an option for
circumventing the limit, but would require support in the app. why does j2me
hate streams?
On Tue, Apr 19, 2011 at 8:39 PM, Clayton Sims csims@dimagi.com wrote:
Derek,
Yeah, the limits will vary per phone and the amount of memory made
available to the app. I'll see if we're doing something naive that might
increase the audio capacity, but other than that Drew's tricks should
hopefully get you to more like a minute of audio.
-Clayton
On Tue, Apr 19, 2011 at 8:59 AM, Drew Roos droos@dimagi.com wrote:
also, using variable bit-rate encoding (VBR) and a quality encoder (i.e.,
LAME) can get you more bang for your buck... err, byte.
On Tue, Apr 19, 2011 at 5:23 PM, Drew Roos droos@dimagi.com wrote:
i also recently encountered this error. note to self: don't use wav
files!
also, voice prompts can get by with a much lower bitrate. 64 kpbs mono
should be adequate.
There is some limit to the file size of multimedia files for use in
CommCare applications, which if surpassed will land you a "Out of
memory error java/lang/OutOfMemoryError". The file size limit is
somewhere between 411kb (works fine) and 644kb (out of memory). A 411kb
audio file corresponds to ~25 seconds of 128kbps mp3.
I know some of you have encountered this error before, so feel free to
share more details here if useful.
further instructions for those who don't use Linux are coming soon.
If any of you users have something to add, feel free to edit the wiki!
Amelia
···
On Tue, Apr 19, 2011 at 1:09 PM, Clayton Sims wrote:
> We are actually steaming the audio when we play it, so I'm not sure why
> there should be any inherent limit to the file size.
> -Clayton
>
> On Tue, Apr 19, 2011 at 12:32 PM, Drew Roos wrote:
>>
>> also, playing multiple clips back to back could be an option for
>> circumventing the limit, but would require support in the app. why does j2me
>> hate streams?
>>
>> On Tue, Apr 19, 2011 at 8:39 PM, Clayton Sims wrote:
>>>
>>> Derek,
>>> Yeah, the limits will vary per phone and the amount of memory made
>>> available to the app. I'll see if we're doing something naive that might
>>> increase the audio capacity, but other than that Drew's tricks should
>>> hopefully get you to more like a minute of audio.
>>> -Clayton
>>>
>>> On Tue, Apr 19, 2011 at 8:59 AM, Drew Roos wrote:
>>>>
>>>> also, using variable bit-rate encoding (VBR) and a quality encoder
>>>> (i.e., LAME) can get you more bang for your buck... err, byte.
>>>>
>>>> On Tue, Apr 19, 2011 at 5:23 PM, Drew Roos wrote:
>>>>>
>>>>> i also recently encountered this error. note to self: don't use wav
>>>>> files!
>>>>>
>>>>> also, voice prompts can get by with a much lower bitrate. 64 kpbs mono
>>>>> should be adequate.
>>>>>
>>>>> On Tue, Apr 19, 2011 at 4:42 PM, Derek Treatman wrote:
>>>>>>
>>>>>> Hello all,
>>>>>> There is some limit to the file size of multimedia files for use in
>>>>>> CommCare applications, which if surpassed will land you
>>>>>> a "Out of memory error java/lang/OutOfMemoryError". The file size limit is
>>>>>> somewhere between 411kb (works fine) and 644kb (out of memory). A 411kb
>>>>>> audio file corresponds to ~25 seconds of 128kbps mp3.
>>>>>> I know some of you have encountered this error before, so feel free to
>>>>>> share more details here if useful.
>>>>>> Cheers,
>>>>>> Derek
>>>>
>>>
>>
>
>
? We'll add it to the queue and let you know if there's a workaround you
can take advantage of in the mean time.
-Clayton
···
On Sun, Dec 16, 2012 at 2:24 AM, Peter D Lubambi wrote:
Hi all,
My application land me to this out of memory error at the end of
registration form and i am not using any audio in my app.
see attached registration form attached. Any Idea what could be causing
this?
I am using nokia C2.
Thank you.
On Tuesday, April 19, 2011 3:12:18 PM UTC+3, Derek Treatman wrote:
Hello all,
There is some limit to the file size of multimedia files for use in
CommCare applications, which if surpassed will land you a "Out of memory
error java/**lang/OutOfMemoryError". The file size limit is somewhere
between 411kb (works fine) and 644kb (out of memory). A 411kb audio file
corresponds to ~25 seconds of 128kbps mp3.
I know some of you have encountered this error before, so feel free to
share more details here if useful.
The error java.lang.OutOfMemoryError: Java heap space usually indicates to us that the application is exhausted with the allocated memory in the Java heap. This is caused by objects not being fully released between tests. You can try to increase the heap size using JVM options such as -Xms and -Xmx. Verify the behavior after increasing memory. If the issue still persists, then it could be most likely caused by excessive object allocation or a memory leak in the application.
Here, the java.lang.OutOfMemoryError typically seems to be caused by exceeding the effective memory limits imposed by the device. It’s not strictly because of the file size you use. The real issue is how multimedia files are loaded into memory. Even relatively small files can consume significantly more RAM when decoded or buffered for playback.
Mobile devices, especially lower-end ones, will have strict per-app heap limits. Now, suppose a multimedia file requires a large contiguous memory allocation (for decoding or processing), it can result in an OutOfMemoryError. This may happen even if the file size seems modest. In order to reduce or overcome this, you can try to test applications on lower-memory devices to understand practical limits.
If you are interested in learning about the types of OutOfMemoryError, you can check out this blog: “Types of OutOfMemoryError, Causes, and Solutions”. Also, You can check out this blog “How to Solve OutOfMemoryError: Java heap space" to understand more about this Java Heap Space error.
Thank you for sharing this detailed explanation about the OutOfMemoryError and the technical background, rakeshjogi! You've provided some helpful context about how memory allocation works in Java applications.
You're absolutely right that this error relates to heap memory exhaustion and that the issue isn't just about file size, but how multimedia files are decoded and loaded into memory—especially on resource-constrained mobile devices.
However, I should note that the standard JVM options like -Xms and -Xmx won't apply in this context, since this discussion is about CommCare running on mobile devices (particularly older J2ME/feature phones), not desktop Java applications. The memory available to the app is controlled by the device itself, not configurable JVM parameters.
Key Takeaways from This Thread:
For anyone encountering OutOfMemory errors with multimedia in CommCare:
Optimize audio file encoding:
Use MP3 instead of WAV files
Use lower bitrates (64 kbps mono is usually adequate for voice prompts)
Use Variable Bit-Rate (VBR) encoding with quality encoders like LAME
Keep files small—around 411kb seems to be a safe threshold on many devices
Device limitations matter:
Lower-end phones (like the Nokia C2 mentioned by Peter) have stricter memory limits
The same file may work on one device but fail on another
For OutOfMemory errors without multimedia:
As Peter experienced, these errors can occur even without audio files
This may indicate the form itself is too complex or there's another issue
If You're Experiencing This Issue:
If you're getting OutOfMemory errors in your CommCare application, please submit a support ticket at support@dimagi.com using the Bug Report Template.
Include:
Device model and specifications
Form/app details (or attach your form XML)
Whether you're using multimedia files (and their sizes/formats)
Steps to reproduce the error
The CommCare team can help identify whether it's a multimedia issue, form complexity issue, or something else entirely, and provide targeted solutions or workarounds.
Additional Resource: Amelia mentioned a wiki page with detailed information about using audio in CommCare. While the old Confluence link has likely moved, you can find current multimedia guidance in the CommCare Public documentation.