开发者

java memory usage [closed]

开发者 https://www.devze.com 2023-01-30 01:57 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago. 开发者_StackOverflow中文版

how the java memory works whenever a new class is instantiated, and when it gets garbage collected, etc.

And also there is difference in memory usage for the collection classes. For eg:Vector takes more memory than hash map like that.

Thanks in advance


Classes are not instantiated, rather classes are defined and objects from those classes are instantiated. when a object is instantiated using new operator memory is allocated.


When a new object is instantiated it takes up memory, when it is no longer used, it frees up memory. More items you put in a collection more memory it will take. When you no longer need an object you want to set to null.

0

精彩评论

暂无评论...
验证码 换一张
取 消