Java Substring memory leak
问题 Based on the discussion about getting substring of String Java String.split memory leak? , I have been analyzing two sample substring examples of usage. It is said that objects don't get garbage collected if the caller stores a substring of a field in the object. When I run the code I get and OutofMemory Exception, and see the incresing of char[] allocated size while monitoring it via VisualVM public class TestGC { private String largeString = new String(new byte[100000]); String getString()