android - How Remove This Exception And What's meaning of this Exception? -
in applicatin occure exception please suggest me how can rectify exception:- have been tried change in imageloader code not success.
//decode image size bitmapfactory.options o = new bitmapfactory.options(); o.injustdecodebounds = true; bitmapfactory.decodestream(new fileinputstream(f),null,o); /* * options.injustdecodebounds = true; bitmapfactory.decoderesource(res, resid, options); // calculate insamplesize options.insamplesize = calculateinsamplesize(options, reqwidth, reqheight); // decode bitmap insamplesize set options.injustdecodebounds = false; return bitmapfactory.decoderesource(res, resid, options); * * * * */ // calculate insamplesize o.insamplesize = calculateinsamplesize(o,100,100); o.injustdecodebounds = false; //find correct scale value. should power of 2. // final int required_size=70; //int width_tmp=o.outwidth, height_tmp=o.outheight; // int scale=1; // while(true){ // if(width_tmp/2<required_size || height_tmp/2<required_size) // break; // width_tmp/=2; // height_tmp/=2; // scale*=2; // } //decode insamplesize // bitmapfactory.options o2 = new bitmapfactory.options(); // // o2.insamplesize=2; return bitmapfactory.decodestream(new fileinputstream(f), null, null);
what wrong in above code because exception occure in section...
06-28 10:53:36.676: e/dalvikvm-heap(595): 960000-byte external allocation large process. 06-28 10:53:36.806: e/graphicsjni(595): vm won't let allocate 960000 bytes 06-28 10:53:36.836: e/androidruntime(595): fatal exception: asynctask #1 06-28 10:53:36.836: e/androidruntime(595): java.lang.runtimeexception: error occured while executing doinbackground() 06-28 10:53:36.836: e/androidruntime(595): @ android.os.asynctask$3.done(asynctask.java:200) 06-28 10:53:36.836: e/androidruntime(595): @ java.util.concurrent.futuretask$sync.innersetexception(futuretask.java:274) 06-28 10:53:36.836: e/androidruntime(595): @ java.util.concurrent.futuretask.setexception(futuretask.java:125) 06-28 10:53:36.836: e/androidruntime(595): @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:308) 06-28 10:53:36.836: e/androidruntime(595): @ java.util.concurrent.futuretask.run(futuretask.java:138) 06-28 10:53:36.836: e/androidruntime(595): @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1088) 06-28 10:53:36.836: e/androidruntime(595): @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:581) 06-28 10:53:36.836: e/androidruntime(595): @ java.lang.thread.run(thread.java:1019) 06-28 10:53:36.836: e/androidruntime(595): caused by: java.lang.outofmemoryerror: bitmap size exceeds vm budget 06-28 10:53:36.836: e/androidruntime(595): @ android.graphics.bitmapfactory.nativedecodestream(native method) 06-28 10:53:36.836: e/androidruntime(595): @ android.graphics.bitmapfactory.decodestream(bitmapfactory.java:470) 06-28 10:53:36.836: e/androidruntime(595): @ com.rentfaster.utilities.imageloader.decodefile(imageloader.java:161) 06-28 10:53:36.836: e/androidruntime(595): @ com.rentfaster.utilities.imageloader.getbitmap(imageloader.java:94) 06-28 10:53:36.836: e/androidruntime(595): @ com.rentfaster.handler.detailphotohandler.imagefecher(detailphotohandler.java:211) 06-28 10:53:36.836: e/androidruntime(595): @ com.rentfaster.handler.detailphotohandler.characters(detailphotohandler.java:153) 06-28 10:53:36.836: e/androidruntime(595): @ org.apache.harmony.xml.expatparser.text(expatparser.java:165) 06-28 10:53:36.836: e/androidruntime(595): @ org.apache.harmony.xml.expatparser.appendbytes(native method) 06-28 10:53:36.836: e/androidruntime(595): @ org.apache.harmony.xml.expatparser.parsefragment(expatparser.java:518) 06-28 10:53:36.836: e/androidruntime(595): @ or g.apache.harmony.xml.expatparser.parsedocument(expatparser.java:479) 06-28 10:53:36.836: e/androidruntime(595): @ org.apache.harmony.xml.expatreader.parse(expatreader.java:318) 06-28 10:53:36.836: e/androidruntime(595): @ org.apache.harmony.xml.expatreader.parse(expatreader.java:275) 06-28 10:53:36.836: e/androidruntime(595): @ com.rentfaster.home.propertydetail$photostask.doinbackground(propertydetail.java:1174) 06-28 10:53:36.836: e/androidruntime(595): @ com.rentfaster.home.propertydetail$photostask.doinbackground(propertydetail.java:1) 06-28 10:53:36.836: e/androidruntime(595): @ android.os.asynctask$2.call(asynctask.java:185) 06-28 10:53:36.836: e/androidruntime(595): @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:306) 06-28 10:53:36.836: e/androidruntime(595): ... 4 more
you can see answer on same issue.
if want more help, please let me know.
thank :)
update:
you have used:
bitmapfactory.decodestream(new fileinputstream(f),null,o);
this method creates bitmap , returns bitmap, not catching bitmap.
you should use like:
bitmap bmp = bitmapfactory.decodestream(new fileinputstream(f),null,o);
you should create options first , call decodestream()
method. there no effect of creating options after calling method.
you have used options, try use possible options can use, following:
options.inscaled = true; options.inpurgeable = true; // scale image 1/8 options.insamplesize = 8;
always call bitmap.recycle()
method have used bitmap.
if these solutions not work, have suggested, use mat eclipse
plugin, because, u'd having memory leak in code.
Comments
Post a Comment