commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Turner <A.G.D.Tur...@leeds.ac.uk>
Subject RE: [io] OutOfMemory exception in IOUtils.toByteArray
Date Tue, 08 Mar 2016 13:07:14 GMT
You can try and catch the OutOfMemoryError:

try {
doSomething();
} catch (OutOfMemoryError e) {
Boolean a = true; // Stop the debugger here
}

To handle this really though you want a reserve bit of memory to release and have a way to
swap some of your data used by your application from the fast access memory to another store
(assuming you need it later, if not just delete all references to it and leave it to garbage
collection).

HTH

Andy
http://www.geog.leeds.ac.uk/people/a.turner/index.html
  


-----Original Message-----
From: Julio Oliveira [mailto:julio.juliooliveira@gmail.com] 
Sent: 08 March 2016 13:00
To: Commons Users List <user@commons.apache.org>
Subject: Re: [io] OutOfMemory exception in IOUtils.toByteArray

Try to use Exception ( this is for all errors )

On Tue, Mar 8, 2016 at 9:50 AM, Zishan J. <zishanj@programmer.net> wrote:

> Hello,
>
> I am using Commons.io.IOUtils library in my android application. I 
> have received this error:
>
> Fatal Exception: java.lang.OutOfMemoryError
>        at org.apache.commons.io.output.ByteArrayOutputStream.needNewBuffer
>        at org.apache.commons.io.IOUtils.toByteArray
>        at com.alhuda.qih.DownloadCompleteReceiver.onReceive
>
> I have tried to catch with IOException but no luck. Is there any way 
> to handle this exception, so I can show the user-friendly message 
> instead of getting the application crashed?
>
> Regards,
> Zishan J.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>


--
Saludos

Julio M. Oliveira - Buenos Aires
http://www.linkedin.com/in/juliomoliveira

Software PYMES - Open Source
http://www.javatango.com/ <http://www.linkedin.com/in/juliomoliveira>
Mime
View raw message