How to make sure String objects are garbage collected in Java -


here code snippet.

method(){     string s1="abc";     string s2 = new string ("abc");     s1=null;     s2=null;     --------     ---------      } 

at end s1 & s2 objects exists? how make sure these objects garbage collected ?

they garbage collected after go out of scope.

unless you're having serious performance issues, i'd stop worrying , let garbage collector it's thing.


you should careful though, there kinds of elements such file streams, open sockets, , such not managed that. have close those.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -