1. It has nothing to do with the GC.
2. A local variable can never have the same name as a global variable. It will point to the global variable.
There isn't enough information here but the two possible causes are:
Globals, unlike Process_Globals, have the same scope as the activity. This means that if the activity was closed and later recreated the globals need to be assigned again.
Or:
Somewhere you assigned null to the global variable (maybe mistakenly assuming that it is a local variable).
BTW, switching to B4XPages will make things simpler as you no longer need to manage the activity life cycle.
Thank you for your reply. However, none of these cases apply, and I think it must be a bug in B4A:
1. I do not nullify the bitmap anywhere, I checked it!
2. Also the Activity is always active and never pauses nor resumes and thus needs no lifecycle solutions.
3. I do not re-dim the bitmap anywhere in any subs (easy to check by searching for "Dim Bitmap1").
4. All png's and jpg's that my app loads into Bitmap1 are valid and present picture files in the DirAssets folder.
My workaround does exactly what I want it to do: revive the global Bitmap1! With the code in #1 all problems are solved. The app never crashes anywhere else, although the global Bitmap1 is re-used hundreds of times in the app.
PS: I never felt the need and also am too old to learn new tricks like B4Xpages (nearly 70 years old...) and am perfectly happy developing without it, sorry!
I tried B4X version-12 but ran into about a 100 problems when trying to convert/upgrade my main app (which I have been working on since 2013), so I gave up.