Gustavo Baiocchi Costa
Gustavo Baiocchi Costa

Reputation: 1448

Private Static Members - Memory Use

I Understand the concept of private static variables. However, I am concern with the memory use of my application.

Question 1: If I create private static members does it imply that they will last for the whole program execution and therefore wasting memory resources?

Question 2: Do private static members differ from public static members in terms of memory usage?

Question 3? What kind of memory they reside on? RAM memory?

Upvotes: 0

Views: 249

Answers (1)

SMA
SMA

Reputation: 37023

Here's what you should be looking for:

  1. Yes from the point when jvm will load your class till your JVM is up and running. You will have just one instance of you static member within whole JVM.

  2. No. Here you are just differing the access specifier i.e. way one class could see the the static member of your class from another class.

  3. Yes they are on RAM.

Upvotes: 2

Related Questions