Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Out ot memory

Miguel AngelAug 9 2010 — edited Aug 10 2010
I got this error: Java lang out of memory when i am saving audio in aByteArrayOutputStream,i can only record about 8 minutes. The initial size of memory is: 256m
My code is:
public void run(){

       int frameSizeInBytes = frtoData.getFrameSize();
       int bufferLengthInFrames = line.getBufferSize() / 8;
       bufferLengthInBytes = bufferLengthInFrames * frameSizeInBytes;
       bufferTemp = new byte[bufferLengthInBytes];

       while (!stopped) {
                if (paused) {
                    synchronized (this) {
                        while (paused) {
                            try {
                                position = (int) (line.getMicrosecondPosition() / 1000000);
                                this.wait();
                            } catch (InterruptedException ex) {
                                Logger.getLogger(Audio.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        }
                    }
                }
                if ((numBytesRead = linea.read(bufferTem, 0, bufferLengthInBytes)) == -1) {
                    break;
                }
                 rewind.write(bufferTemp 0, numBytesRead);
        }
code}

rewind is an object of a class: RewindAudio that extends from ByteArrayOutputStream.
I can save more data audio,about 17 minutes, if i increment the size of memory with this: -Xmx450m, but i have to get to at least 1 hour.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 7 2010
Added on Aug 9 2010
6 comments
241 views