简体   繁体   English

私有静态成员-内存使用

[英]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? 问题1:如果我创建私有静态成员,是否意味着它们将在整个程序执行过程中持续存在,从而浪费内存资源?

Question 2: Do private static members differ from public static members in terms of memory usage? 问题2:就内存使用而言,私有静态成员与公共静态成员是否有所不同?

Question 3? 问题3? What kind of memory they reside on? 它们驻留在哪种内存上? RAM memory? RAM内存?

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. 是的,从jvm加载类直到JVM启动并运行为止。 You will have just one instance of you static member within whole JVM. 在整个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. 是的,它们在RAM上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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