0

Is it good idea store my data objects in static variables of singleton class? I have class AppEngine where are some data static e.g. boolean int and instances of my classes (Configuration etc.)

When these objects are destroyed?

If I want to use them I call it something like this: MyEngine.getMyEngine().getConfiguration().method(arg);

CRUSADER
  • 5,486
  • 3
  • 28
  • 64
SpeedEX505
  • 1,976
  • 4
  • 22
  • 33
  • yes you can do that, infact this way provide the use of those variable all throughout the app, what is the problem you are facing? – Smogger Nov 28 '13 at 13:13
  • After some tests, it's appears that these objects are destroyed when the OS kill your process. When all activity are finished, data are still in memory.. – nbe_42 Nov 28 '13 at 13:15
  • u make singleton class and its work ohk so just see my answer it will help u – Bhanu Sharma Nov 28 '13 at 13:24
  • A word of caution with static variables - never store a reference to a context in them (that includes activities and views) otherwise you'll leak memory. – NigelK Nov 28 '13 at 14:41

1 Answers1

1

no no no dude just put null in that object like this

singltonclassobject = null;

it will destroy. :)

Bhanu Sharma
  • 5,135
  • 2
  • 24
  • 49