Thursday, 15 January 2015

java - OutOfMemory error while creating chunks of large file in android -



java - OutOfMemory error while creating chunks of large file in android -

i trying read file , uploading server 1 mb chunk size. working fine upto 13 mb after give me outofmemory exception. have checked buffer , 1mb of size don't know why getting exception. 1 thing predict previous read bytes not getting free scheme tried find way free there not method byte[] free.

bytearrayoutputstream bytebuffer = null; seek { bytebuffer = new bytearrayoutputstream(); byte[] buffer = new byte[maxchunksize]; int len = 0; int startpoint = 0; while ((len = is.read(buffer)) != -1) { log.i("upload chunk",""+buffer.length); bytebuffer.write(buffer, 0, len); string uploadresponse = uploadchunk(filehandle, buffer, startpoint, emailid); if(!uploadresponse.equals("chunk added")) { log.e("upload chunk", "something went wrong. aborting upload"); break; } startpoint += buffer.length; }

can 1 help me issue resolved? file max size 25mb.

this exception getting.

06-26 22:49:22.329: e/androidruntime(15645): java.lang.outofmemoryerror 06-26 22:49:22.329: e/androidruntime(15645): @ java.io.bytearrayoutputstream.expand(bytearrayoutputstream.java:91) 06-26 22:49:22.329: e/androidruntime(15645): @ java.io.bytearrayoutputstream.write(bytearrayoutputstream.java:201) 06-26 22:49:22.329: e/androidruntime(15645): @ com.desiengineer.backgroundtask.evidenceuploadservice.onhandleintent(evidenceuploadservice.java:101) 06-26 22:49:22.329: e/androidruntime(15645): @ android.app.intentservice$servicehandler.handlemessage(intentservice.java:65) 06-26 22:49:22.329: e/androidruntime(15645): @ android.os.handler.dispatchmessage(handler.java:99) 06-26 22:49:22.329: e/androidruntime(15645): @ android.os.looper.loop(looper.java:137) 06-26 22:49:22.329: e/androidruntime(15645): @ android.os.handlerthread.run(handlerthread.java:60)

delete bytearrayoutputstream. not using it, , source of memory problem.

java android

No comments:

Post a Comment