1
我有一个HashMap,它是Student类型的。学生是一个用户定义的对象,它由几个属性以及一个名为College的其他用户定义对象组成。现在,在使用之后,我想清除HashMap使用的所有内存,并依次清除Student和College对象使用的所有内存。所以,虽然无效,我是否需要显式无效Student和College对象,然后将NULL引用分配给HashMap对象?或者只给HashMap对象分配NULL会释放Student和College对象使用的内存?清除集合对象中的引用
Map<String, Student> myMap = new HashMap<String, Student>
Student std = myMap.get("");
College col = std.getCollege();
col = null; std = null;
myMap = null;
我需要做上述所有以释放内存HashMap的使用?或者取消HashMap将释放所有的内存?
对这个家伙有什么帮助? – Nikhil 2015-04-14 10:18:49