Java Assignment Memory Leaks

chakabito

New Member
I have to assume that the following method doesn't leak memory:\[code\]public final void setData(final Integer p_iData){ data = http://stackoverflow.com/questions/7652106/p_iData;}\[/code\]Where \[code\]data\[/code\] is a property of some class.Every time the method gets called, a \[code\]new Integer\[/code\] is replacing the currently existing \[code\]data\[/code\] reference. So what's happening with the current/old data?Java has to be doing something under the hood; otherwise we'd have to null-out any objects every time an object is assigned.
 
Back
Top