Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OutOfMemoryError when writing to SharedPreferences file

I've found this curious OutOfMemoryError, I wondered if anyone else had come across it. I am breaking the rules of SharedPreferences slightly and storing a couple of model objects as strings but these are small.

java.lang.OutOfMemoryError
at com.android.internal.util.FastXmlSerializer.(FastXmlSerializer.java:55)
at com.android.internal.util.XmlUtils.writeMapXml(XmlUtils.java:177)
at android.app.SharedPreferencesImpl.writeToFile(SharedPreferencesImpl.java:596)
at android.app.SharedPreferencesImpl.access$800(SharedPreferencesImpl.java:52)
at android.app.SharedPreferencesImpl$2.run(SharedPreferencesImpl.java:511)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
like image 306
scottyab Avatar asked Mar 17 '14 16:03

scottyab


1 Answers

OOM errors can happen anywhere in the App.

It's just saying: hey, I tried to allocate something but I were out of memory. Sorry.

This can happen: you load a very big image in your app and are left with very few bytes available before OOM: you then have a simple parser allocating strings and stuff.. that can go OOM.

Your problem is elsewhere :)

like image 54
Daniele Segato Avatar answered Nov 15 '22 01:11

Daniele Segato