1. Operation such as
- String.split()
- String.substring()
uses offset values but keep the ORIGINAL char[] value. Therefore, if you only ever want a portion of the String it will WASTE memory space by storing the original string value
http://stackoverflow.com/questions/7629208/substrings-and-garbage-in-java-1-6
2. For String.substring()
to get just the portion of the substring, recommend to use
String sub = new String(str.substring(6,12));
3. General String related:
http://www.javamex.com/tutorials/memory/string_memory_usage.shtml
No comments:
Post a Comment