This is a really interesting question!
There is a difference in the behavior of System.exit() for the Java SE API and the BB Java API:
- In the Java SE API: the currently running Java virtual machine ends.
- In the BB Java API: the currently running Java application ends.
Also check out what Carol Hamer and Andrew Davison said in the Blackberry Games Evolution Study:
Warning: the BlackBerry platform does not run your application in a separate virtual machine, which means that you have to be very careful in cleaning. The remnants of an earlier run (for example, static variables and other data stored in memory) could potentially affect subsequent application runs. It also means that theres is a global namespace, so if two classes have the same name, errors can occur.
So yes, there is the only JVM device for BB. And yes, in a BB application, calling System.exit() just stops your application, leaves all your static data in RAM, unless you do a preliminary cleanup .
Thus, you should not avoid System.exit() - this is the legal / correct way to close the BB application , but just do the cleanup before this call .
UPDATE:
by email Oh. I created a test application (using JDE 4.7.0 + Storm 9530 4.7.0 simulator) to check if static material really remains in RAM after calling System.exit() . And it turns out that he no longer stays there. The next time I enter the application, the static variables are zero (as expected, they will be in Java SE). Therefore, it is not clear to me that Carol Hamer and Andrew Davison say that "remnants of an early run (such as static variables and other data still in memory) can potentially affect subsequent runs of the application."
source share