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
.
精彩评论