I read that in Google App Engine there is a chance that a singleton class might die, if the application gets idled for too long (or a new application instance is created), and I have experienced this myself.
But does that really mean that Any static variable in any class might get expired in the application? or how can GAE identify that this class is a singleton?
App Engine can and will unload applications that are idle for a
longundefined period of time. In other words, you application will essentially be shut down.In addition, GAE may run your application in many processes across many servers if your traffic is high enough.
So really, relying on static members or even Singletons is probably a bad idea in such an environment – with GAE you are not in control of when your application is started/stopped/loaded on other machines.
These two questions in the GAE Java FAQs partially address this:
edit: I should say that "long period of time" is actually undefined, and I don’t think Google publishes it. It would be more correct to say App Engine will unload applications that are idle for some undefined period of time.