简体   繁体   中英

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?

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 ie way one class could see the the static member of your class from another class.

  3. Yes they are on RAM.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM