i am calling setABC(id)
on click multiple times.
MyClass _globalObject;
setABC(id)
{
_globalObject = new MyClass(id);
}
Does the garbage collector destroys old object from memory and assign new object to _globalObject
or it just create a new object and assign to _globalObject
, consuming memory every time i call setABC(id);
(edit) maybe i didn't phrased it well, i don't concern about when GC occurs, rather will the following code destroy old object in memory and assign new object to _globalObject
by not consuming memory more then once for on multiple calls.
_globalObject = new MyClass(id);