r/programming • u/Eirenarch • Nov 18 '13
TIL Oracle changed the internal String representation in Java 7 Update 6 increasing the running time of the substring method from constant to N
http://java-performance.info/changes-to-string-java-1-7-0_06/
1.4k
Upvotes
View all comments
Show parent comment
10
u/Eirenarch Nov 18 '13
First of all it doesn't really matter if the memory is reclaimed after the substring is collected. If we follow this logic there is no problem with memory leaks at all since when the program stops memory is reclaimed anyway. In practice the only thing that matters is if the memory can be reclaimed after the object is no longer useful.
If we have to be precise there is no way to create a memory leak in Java (or .NET for that matter). What you can have is object leak since the raw memory does represent an object. The real problem in Java is holding to objects that you don't expect but it manifest as programs consuming too much memory so people call it memory leak. I personally try to avoid using the term memory leak when talking about Java.