String humongous= ... ; // an extremely big String
String small= humongous.substring(0, 1): // a very small String
humongous= null; // free the big one?
The substring() method shares its char[] buffer with the String for which it is a substring and the entire String buffer can not be garbage collected. Line two from the above code snippet had better written as:
Leave a comment: