(Title is misleading since garbage collectors collect only objects, but I found this title more straightforward)
Suppose I have an Android application with a static variable named "userid" inside a class called Global (which is null at initialization time).
If I set "userid" variable to some value duing Android application lifecycle, say Global.userid = "myid", is it possible for this variable to become null while Android application is still alive?
In other words, is it possible for Android VM to unload Global class and "kill" this global static variable due to low-memory issue without killing the whole Android application?
I am worried about the situation that userid becomes suddenly null while application is running (due to low memory issue), therefore crashing the whole app.
Edit
I was misunderstanding some concepts (between application process vs activities). Thanks for all answers!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…