Memory issues with multiple screens?


#1

Hi

I have a somewhat complex app that uses about 4-5 screens. I have tried both Taifun’s as well as Tribblehunters method of closing and opening screens. I have made sure there are no big images on the screens (most of the screens fetch data from SQLIte and display that data using listviewer with jquery (using a webviewer).

I can get through one cycle of the app fine, but then the app starts crashing at random points in the 2nd cycle with the message “Unfortunately, has stopped working”.

Seems to me that each screen takes up memory and apparently, that doesn’t get freed even on screen close, which would explain the behavior. Is that the case, and if so, is there a work-around? Collapsing the screens into just 2-3 screens by making vertical arrangements visible/invisible doesn’t really work as the screens become too complex to edit.

Any ideas would be greatly appreciated.

Thanks


pt


App keep crashing ! Need help!
Open and Close screens at the same time
#2

Hey! Welcome to Thunkable!

This may help you:


#3

to find out more about the Runtime Error, you can use Logcat

I normally use Eclipse and Logcat there, but if you have installed the App Inventor Software (see also http://appinventor.mit.edu/explore/ai2/setup-emulator.html), you already have everything you need to use logcat…

How to use Logcat

  1. connect your device using USB with your computer

  2. in File Manager go to the App Inventor directory, which is C:\Program Files\App Inventor or similar

  3. press Shift and right mouse click the subdirectory commands-for-Appinventor to get the context menu

  4. select “open command window here” and you will get a command window of that subdirectory

  5. enter *adb logcat :E and the logcat will start running and log all errors

  6. start your app to elicit the error

  7. copy the log (see below)

To copy your log, right click, click “select all” and enter to copy the complete log into the clipboard, then open Notepad and paste it using ctrl-v.

Taifun


[Free] Extension Sidebar Navigation Update 12/04/2018
Why does my app crash?
Compatibility on Google?
Incompatible extensions?
[Free] Extension Sidebar Navigation Update 12/04/2018
OCR extension crashes app
Android Bug to open App
Yail compiler DX execution failed
Sorry the app has stopped...this happens in a cycle sometimes
[Free] ActionBar Extension
Gyro + GPS + Foto Button = crash in Android 7 every time
App compiles ok and runs for a while - but then silently dies - Memory leak?
Spreadsheet error
#4

@P_T ive had that issue before. Somewhere in your many blocks there is usually 1 block that is missing or incorrect. It takes a while but you gotta find it. The little yellow and red error indicators on the bottom left of the blocks editor can help. send me a privet message if you need more help. One other thing to make sure of is that when you change screens, it closes the old screen. otherwise it seems to chew memory.


#5

I have followed all the threads on app crashing due to memory issues but with no luck. I even reduced the app to use only 2 screens (Screen1 and Photos) with each screen having 2 virtual screens (vertical arrangements with hide/show function).
I have also compressed all images used in the app (as button icons and banner images) using tinypng.com. Yet, I only get 2 or 3 cycles before the app crashes when returning to the main screen (Screen1). Screen1 is what you would call my Screen Manager where all other windows are called and/or displayed onButtonClick().

Please see aia file and I welcomemyService3.aia (174.9 KB)
your thoughts. I reduced the app to 2 screens because of trying to avoid too many screens that slowed down the app when loading before.

Thanks.


#6

I am running Mac OSX. I changed to the folder containing the adb program as suggested. I listed the directory contents and do see adb. But when I run the command adb logcat *:E, I get no such command error.

Uum. ANy ideas ? Is the instruction different for Mac?


#7

what happens, if you try just adb logcat? Sorry, I’m not familiar with Mac…

you are using some large icons 512x512 inside your app, what about following these recommendations: Using Images with App Inventor and use images, that are “just the right size”?

Taifun


#8

I have reduced all image sizes down to 64x64 resulting in about 12k in size per icon image. I will try again to see if this helps and resolves the crash issue .I believe it would help but not sure if the back and forth from the screen manager to the only other screen in the app will consume the available memory over a period of use.

I know one can’t close the screen manager wihtout exiting the application, but does opeining another screen free up memory while in another screen? But if not, how does one free memory when the screen1 is not in use? I ask because i a afraid that over time the memory taken up by the app icon images will run out even though their sizes have been drastically reduced.

Your professional expertise, advice, and pointers are sorely needed. Thanks


#9

in case you still have issues, then you might want to try Tribblehunter’s method
Taifun


#10

As I suspected, I was able to run the app for more cycles (7) after image resolution and size reductions compared to 2 earlier before it crashed. I thought I was applying the Trbblehinter’s method already.

I open Photos Screen from Screen1 and do close it on backspace pressed that returns me to Screen1. I do not open any screen from Photos except to show/hide vertical arrangements.
Can you please review my blocks for these two screens to see what may need revision to comply with the recommended method? It is obvious that image size reduction is not a solution. I would have been ok with the loss of image quality if it worked.

Thanks for your help


#11
  1. you have to use the same method of switching screens in all screens and
  2. you have to follow the image size recommendations

sorry, I do not have time currently to take a look at your app
it looks like you do not switch screens correctly…
you might want to provide some screenshots which show us, how you are switching the screens…

Taifun


#12

I ma sorry to be a bother and not having been cleaar enough to get appropriate help. Per your request, I am attaching screenshots of my 2 screens (Screen1 and Photos) that contain other virtual screens (vertical arrangements activated with hide/show on each screen).

Screen1 calls only Photos screen via the menu icons and then decides which virtual screen needs to be made visible using tghe screen startvalue param passed via the “opne another screenname …”. A screenManager procedure is called on the Photos screen to perform the hide/show function.

Hope this is clearer than my earlier postings; especially with the attached screenshots. Thanks a million for your help and sorry to be persistent and bothersome in my asking for help.


#13

as we can see, you are using the manager screen method…
the blocks look fine…
in the Photo screen how do you switch between the virtual screens?
as already suggested, you might want to try Tribblehunter’s method instead…

Taifun


#14

In the Photo screen, the switch between virtual screens (vertical arrangements) is done by hiding and showing the relevant vertical arrangements. They are not screens so can’t use “close screen” method or can you?

If you can, then I will appreciate any hints on how. The method you recommended is for switching between real screens as far as I could read. If not I will be glad to adopt it.

Thanks for your patience and assistance.


#15

that’s fine…
Taifun


#16

Thanks Talfun for your patience with me and assistance. Now with the switch being fine and all images reduced/optimized, I wonder where the source of crash now is. I am inclined to refactor the app into using separate screens for each menu. However, my fear is that 9 separate screens will have to be created which may slow application bootup and cause other performance issues.

I want to believe that this sort of app architecture ( a menu screen calling other windows) should be feasible also in App inventor since only one screen is open at a time. I have seen similar apps on the marketplace; probably created with textual programming language where memory management is enforced literally.

I will try creating separate screens and see if that works; unless I get some insights of what to improve in my app without multiple screens beyond one.

Thanks partner.


#17

yes, exactly
did you try Tribblehunter’s method as suggested?

use as less screens as necessary and follow the KISS principle

Taifun


#18

The Tribblehunter’s method is what I am trying to use now by breaking the app into multiple screens of 9 total! Unfortunately, it may be of no consequence since I am not calling any other screens from a child screen that will require a child screen to close itself before calling its sibling screen. All of my screens will be called from the home screen (Screen1) and thus situation will not be different from what I currently have where return to screen1 is crashing the app after 2 or 3 cycles.

Talfun, It is the attempt at using the KISS principle that led me to just 2 screens (Screen1 and Photos) as in the aia file I shared with you. But even with that, I have the ongoing problem of app carsh. I am closing the only other screen (Photos) that is opened from screen1 and as you reviewed the blocks look ok. So I am at a loss.

I was just going to try using more screens as a test to see if the virtual screens are the cause of my issues. I am not sure why I am having these crashes given that I only have 2 screens and kind of in a bind.

It is not my idea to make things complex but the app functionality calls for accessing different views depending on which menu icon is clicked. How else would one implement such an app? I am teachable and would like to learn and not sure I am doing anything out of the ordinary as apps with such architecture do exist.

I also thought of doing a Facebook menu type (side sliding menu) but my knowledge is not advanced to that level yet. Maybe that architecture could help eliminate the issues.

Thanks for your support and any other ideas. This one is stumping the experts as well as me (a rookie). Lol!


#19

this is not what Tribblehunter’s method is about
the method is about closing the current screen while opening another screen
my suggestion is to still use only 2 screens and try the Tribblehunter method
also it would be great to use logcat to find out, what exactly the error is…

Taifun


#20

My good news report follows. Talfun, I greatly appreciate your advice and assistance. I am happy to report that I have implemented 5 screens, performed a stress test of 20 cycels with no CRASH using the Tribblehunter gotoScreen procedure snippet. What I don’t know happens is if the main screen (Screen1) was being closed every time I call another screen from Screen1 per the code snippet. I was afraid my main screen (Screen1) will close thereby exiting my application and hence my initial apprehension of how the method would work.

Neverthless, so far so good, I will continue testing by now implementing my most demanding screen to see if it works. You’re right though, that my initial implementation may be too complex in the goal of not using too many screens.

I will try and see what happens with the original design by applying the Tribuhunter’s method too. Thanks