java - Outofmemory Exception using retrofit library android -
i using retrofit library download apk file server. getting outofmemory exception since 8 mb file.
06-04 17:02:36.242: i/dalvikvm(32227): "asynctask #1" prio=5 tid=12 runnable 06-04 17:02:36.242: i/dalvikvm(32227): | group="main" scount=0 dscount=0 obj=0x40fc7eb8 self=0x2a1096a8 06-04 17:02:36.242: i/dalvikvm(32227): | systid=32247 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=705879936 06-04 17:02:36.242: i/dalvikvm(32227): | schedstat=( 1325450565 1518168555 7526 ) utm=87 stm=45 core=0 06-04 17:02:36.242: i/dalvikvm(32227): @ java.io.bytearrayoutputstream.expand(bytearrayoutputstream.java:~91) 06-04 17:02:36.242: i/dalvikvm(32227): @ java.io.bytearrayoutputstream.write(bytearrayoutputstream.java:201) 06-04 17:02:36.242: i/dalvikvm(32227): @ retrofit.utils.streamtobytes(utils.java:44) 06-04 17:02:36.252: i/dalvikvm(32227): @ retrofit.utils.readbodytobytesifnecessary(utils.java:81) 06-04 17:02:36.252: i/dalvikvm(32227): @ retrofit.restadapter$resthandler.invokerequest(restadapter.java:348) 06-04 17:02:36.252: i/dalvikvm(32227): @ retrofit.restadapter$resthandler.invoke(restadapter.java:240) 06-04 17:02:36.252: i/dalvikvm(32227): @ $proxy0.getapkfile(native method)
my code:
restadapter restadapter = new restadapter.builder() .setendpoint(url).setloglevel(restadapter.loglevel.headers) .build(); //restadapter.setloglevel(restadapter.loglevel.none); typedbytearray bytearray=((typedbytearray)restadapter.create(apkdownloadinterface.class).getapkfile().getbody()); try { log.i("", "length "+bytearray.length()); bufferedinputstream bis=new bufferedinputstream(bytearray.in()); bufferedoutputstream bos=new bufferedoutputstream(fos); byte array[]=new byte[1024]; int x=0; while((x=bis.read(array))!=-1){ //log.i("", "transferring data"); bos.write(array, 0, x); } bos.close(); bis.close(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); }
Comments
Post a Comment