java - Static variables : How to reclaim memory? -
i created service keeps running @ background - should never go offline.
with each smaller module plug-in service i'm little worried static variables need use. since parent service , running (let's never goes down - perfect scenario), won't static members take lot of heap memory time? cause service crash?
from know, static variables persist till program termination - in case never!!
is there workaround this? can somehow call independent modules , not think of memory used static variables - there way run independently , not end killing jvm or service?
ps - don't think can away static members, need know if there's efficient way of using static members , not wasting lot of memory.
i don't think static data members issue here. oop design aspect think about, it's not related memory concerns.
you should first estimate size of memory program needs, , decide whether want keep data in main memory during lifetime of application. possible outcomes of analysis can be:
- the data must kept, , fit in memory - configure -xmx flag accordingly , test assumptions.
- the data must kept, , there isn't enough space - consider using persistency (e.g. db)
- the data doesn't have kept - consider using bounded cache, old/irrelevant data items evicted.
Comments
Post a Comment