App crashes (out of memory?)


#1

My app keeps crashing after the 8th opening of another screen and coming back to the ScreenManager (Screen1). I know that i must make the app close the unused screens before opening another one, so i made it - now if i am in screen 2, if you want to go to another screen, it will first close it. But how can i make the Screen1 close every time i open another screen coming from Screen1? Is this the reason my app keeps crashing?
Also could it be that the pictures i use are too much/too big? I use about 45 images in my app and they are between 300x300 and 400x600 at most.
Any tips?


#2

Probably because of this size and how many you have, also depends on how many other components you have, etc.

Even when you close screen the memory of the screen will not be released immediately, it depends on your Android version how it manages this.

/Boban


#3

_ understand… so my app is only images and i have about 4-5 of the 400x600 images and they are 1 on every screen or so. But i can’t close the Screen1, right? Because i think the problem comes from that issue…_


#4

Could you show some related blocks on how you switch screens and close screens.

Btw, do you have any Clock/Timers on screen1

/Boban


#5

I use a simple app where you can only go to another screen from the Screen1 and from any other screen you can only return with the back button. So i use the block if screen backpressed, close screen on every screen other than screen1. Screen1 is never being closed, which worries me, is this the problem?


#6

alternatively you might want to try

Tribblehunter’s Multiple Screen Method

Taifun


#7

Hm, i did it, it looks like it must be working, but instead, now the app crashes even faster (only after the 4th screen open)… i really dont know what is going on…


#8

Will the memory problem be solved if i make everything on one screen changing the visibility of the components only? Or will it be harder for the app to run smoothly if it is all in one place (screen1)?


#9

this sounds like you did not use the method on all the screens?
Taifun


#10

You can try this if it helps, remove the image before closing the screen.

/Boban


#11
  1. using only one screen will solve your memory problems,
  2. app will run more smoothly,
  3. of course you won’t have these nice transitions which you can set when switching the screens, but you can make a procedure that will make the transition whenever you want

#12

Thank you! So even if on one screen i place 45 images that will be shown/made not visible, the app will run more smoothly? I will try it and see if it really helps.


#13

Oh, i did use it on all of them… but i think that maybe i will have to make the app on one single screen and so reduce the memory of opening screens… maybe this will work


#14
  1. using only one screen will solve your memory problems,
  2. app will run more smoothly

Well, guess what, now the app doesn’t even open… I am despered… what is going on, nothing is working!


#15

did you read the general recommendations, especially tip 1 and 2?


Taifun