dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Intermediate
Nov 16, 2018

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Relation Between Static Keyword and Memory Allocation

In Java, static keyword usage on variables means that memory is allocated and it will not be possible for the garbage collector to reclaim the memory until the application terminates. To be clear, do not use static keyword for variables that are local (used within a scope).

Use static only for those variables that needs to be accessed across and also be sure that they are not memory intensive ,so that they do not block huge memory allocation.

Also, variables declared as static can exist even without a class instance. So, be sure on the usage of static given the memory that is allocated and never released until the application exits.

M S Sridhar
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date