J
Jonas Hei
Can someone please enlighten us on what happens when an object is set to
null?
class SomeClass {
private int someData;
//more stuff - lots of memory consumed by data here
}
class SomeApp {
private SomeClass someObject = null;
public void someMethod {
someObject = new SomeClass();
//do stuff...
someObject = null; //once we're done it
//Is the above instance of SomeClass
//ready for garbage collection after
//it is set to null above???
//do more stuff...
//can do much better because we've
//(sort of) disposed off the memory
//consumed by someObject - is it true??
}
}
null?
class SomeClass {
private int someData;
//more stuff - lots of memory consumed by data here
}
class SomeApp {
private SomeClass someObject = null;
public void someMethod {
someObject = new SomeClass();
//do stuff...
someObject = null; //once we're done it
//Is the above instance of SomeClass
//ready for garbage collection after
//it is set to null above???
//do more stuff...
//can do much better because we've
//(sort of) disposed off the memory
//consumed by someObject - is it true??
}
}