I'm new to programming, I've been making an app for the last 3 months and learned a few things. But I haven't come across to how to solve this issue. I've been using Parse.com as my server, sending pictures, saving user data etc. With all of this data the app keeps crashing if I open some activities more than a few times, particularly activities with pictures. Now I have compressed the pictures and made them max 400x400 in resolution. But somehow the allocation is out of memory keeps popping up. Does anyone know any methods with which you can solve this? Because when the app crashes in Android Studio the previous memory which was on my phone seems to get deleted (Not all of the cache data).
Thanks.
// EDIT this is the Logcat
**
Out of memory: Heap Size=43591KB, Allocated=14395KB, Limit=49152KB
06-10 03:39:26.220 9344-9344/com.parseapp.eseen.eseen E/dalvikvm﹕ Extra info: Footprint=43591KB, Allowed Footprint=43591KB, Trimmed=21928KB
06-10 03:39:26.220 9344-9344/com.parseapp.eseen.eseen D/skia﹕ --- Unable to allocate space, reportSizeToVM = true
06-10 03:39:26.220 9344-9344/com.parseapp.eseen.eseen W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x40d90390)
06-10 03:39:26.230 9344-9344/com.parseapp.eseen.eseen E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.parseapp.eseen.eseen/com.parseapp.eseen.eseen.LoginActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2355)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391)
at android.app.ActivityThread.access$600(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1335)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5511)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:613)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:369)
at android.app.Activity.setContentView(Activity.java:1912)
at com.parseapp.eseen.eseen.LoginActivity.onCreate(LoginActivity.java:29)
at android.app.Activity.performCreate(Activity.java:5066)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1101)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2311)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391)
at android.app.ActivityThread.access$600(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1335)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5511)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:587)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:369)
at android.app.Activity.setContentView(Activity.java:1912)
at com.parseapp.eseen.eseen.LoginActivity.onCreate(LoginActivity.java:29)
at android.app.Activity.performCreate(Activity.java:5066)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1101)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2311)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391)
at android.app.ActivityThread.access$600(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1335)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5511)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.OutOfMemoryError: (Heap Size=43591KB, Allocated=14395KB)
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:626)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:473)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
at android.content.res.Resources.loadDrawable(Resources.java:1959)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:3354)
at android.view.View.<init>(View.java:3291)
at android.view.ViewGroup.<init>(ViewGroup.java:432)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:184)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:587)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:369)
at android.app.Activity.setContentView(Activity.java:1912)
at com.parseapp.eseen.eseen.LoginActivity.onCreate(LoginActivity.java:29)
at android.app.Activity.performCreate(Activity.java:5066)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1101)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2311)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391)
at android.app.ActivityThread.access$600(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1335)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5511)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
at dalvik.system.NativeStart.main(Native Method)
**
The code is too long to put it here since it's limited to 30,000 chars
If you are using parse.com and getting the Images from database and converting it to bitmaps it will crash your app..
what you should do is, get the image of the URL from parse.com there is method called..
For that implement the Picasso library, which is perfect solution for loading images from database.
To implement picasso in your app,
Then get the file from parse database
To load the file
then just get context and ..add following passing your file url..
Here is the reason, why you should implement this..
ALSO full tutorial will be available from Official website Picasso Library