Minim memory leak related to AudioRecorder
in
Core Library Questions
•
3 years ago
I'm making an application that begins recording once it receives an audio signal above a threshold and ends recording once that falls below the threshold for a few seconds straight. I have set a maximum recording length to 5 minutes consecutively so that it doesn't run out of memory, yet after several recordings (last crash was 10 recordings x 5 minutes each) I get an OutOfMemoryError as it writes to the saved file.
Here is the error (minus the Processing added part):
Exception in thread "Animation Thread" java.lang.OutOfMemoryError: Java heap space
at org.tritonus.share.sampled.FloatSampleBuffer.convertToByteArray(FloatSampleBuffer.java:394)
at ddf.minim.javasound.JSBufferedSampleRecorder.save(JSBufferedSampleRecorder.java:144)
at ddf.minim.AudioRecorder.save(AudioRecorder.java:107)
at AOVAudioRecord.completeRecord(AOVAudioRecord.java:213)
at AOVAudioRecord.draw(AOVAudioRecord.java:136)
at processing.core.PApplet.handleDraw(PApplet.java:1606)
at processing.core.PApplet.run(PApplet.java:1503)
at java.lang.Thread.run(Thread.java:637)
two relevant functions:
- void initRecord()
- {
- currentFilename = getTimestamp() + ".wav";
- recorder = minim.createRecorder(in, currentFilename, true);
- worthSavingCounter.reset();
- recorder.beginRecord();
- }
- void completeRecord()
- {
- recorder.endRecord();
- recorder.save();
- println("Done saving.");
- addRecentFile(currentFilename);
- currentRecordingLength = 0;
- nRecordings++;
- }
1