Application stucks after a while. Can i clean memory at run time?

421 views
Skip to first unread message

demetris christofi

unread,
Oct 25, 2015, 2:21:24 PM10/25/15
to MIT App Inventor Forum
Hello,

Another memory issue i guess.
After using my application, in live testing, the app stuck while pressing a button, remains unresponsive and then crashes.

I have 10-15 images, only 2 screens, and lots of variables

I noticed that this is happening after i initialize some variables for a second time, but it's not clear.

Is there any way to clear the temporary memory/cache of the application at run time?

demetris christofi

unread,
Oct 25, 2015, 4:48:19 PM10/25/15
to MIT App Inventor Forum
Same issue occurs after i build the app, install and run it on my phone.

SteveJG

unread,
Oct 25, 2015, 5:12:16 PM10/25/15
to MIT App Inventor Forum
The app gets stuck.  How do you switch between your screens?   If you are changing screens and not closing the screen you leave, you eventually gobble up system memory.  AI2 users are recommended to close the screen they leave (except for Screen1 which is never closed). the additional screens.  Why?   Each screen created with AI2 'behaves' as if it is a separate app, utilizing its own share of system memory.  If a user moves back and forth, the additional screen memory is never released and I believe the effect is cumulative.  Are you closing screens as you leave them Demetris? 

The issue you described is probably this, but it might be something else related to a memory leak in one of the routines you are using.
There is only one way to clear some memory that I am aware of and that is by closing screens.  When you reinialize variables, I do not know whether this uses additional memory or not; I would suspect it does not but that is a guess.

demetris christofi

unread,
Oct 25, 2015, 5:30:01 PM10/25/15
to MIT App Inventor Forum
Good thing:
I was not aware of the close screen functionality. Now, that i know i will add it to my app.

Bad thing:
When starting developing my app, i didn't know that Screen1 is always the main screen and that i can not even rename it.
Also, due to the fact that AI2 is having hard times with using multiple screens, i developed my app using  just 2 screens.
The sad thing is that 95% of my elements/code is in Screen1.
Screen2 is used as the home screen of my app and everything else belongs to Screen1(i hide/show, enable/disable elements according to what i need to do), which, as you said, is never closed.
So, i guess the problem is that Screen1 is overloaded.

Is there any way to swap the 2 screens? Make Screen2 my primary screen, in order to free Screen1 of such overloading?

Thanks

SteveJG

unread,
Oct 25, 2015, 8:59:48 PM10/25/15
to MIT App Inventor Forum
I have never swapped two screens; perhaps there is something in the discussions here   https://groups.google.com/forum/#!searchin/mitappinventortest/swap$20screens  .

Can a single screen be overloaded ... probably.  A reason for a single screen is to avoid transferring data between screen, which can become complex and convoluted, which does not happen on a single screen.  We do know that a lot of layouts an cause issues.  We know over 10 screens and AI2 starts to become unstable.   Only you as a developer can decide on the proper mix in a LARGE app of when to use screens and when not to.  The more complex the app with lots of blocks strange things start to happen with the entry level compiler.  If the app is huge, Android Studio might be a better platform without the restrictions AI2 has ...and AS has limitations too.

Luck...

Michael L

unread,
Nov 1, 2015, 6:38:38 PM11/1/15
to MIT App Inventor Forum
To: demetris christofi, 

I'm in the same place as you when it comes to Screen One HAVING to be

the main screen. I didnt realise this until I was well into the development of

my App. I did come across a YouTube Video that was posted by 

M. Hossein Amerkashi that you might want to take a look at,

https://youtu.be/XvSiD-iA17Y maybe that will help you out. 

Also remember that you can now copy all the blocks in the block editor 

into the "Backpack" (top right hand corner of the Blocks Editor) and 

open a new or alternate project then paste those blocks into the 

Blocks Editor of that alternate (or New) project.

demetris christofi

unread,
Nov 1, 2015, 6:43:00 PM11/1/15
to MIT App Inventor Forum
I will check this video.

Thanks a lot!!
Reply all
Reply to author
Forward
0 new messages