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
Post a Comment