... but this string creates the same space for original string.so memory leak will happen.

I think you are referring to the behavior of String in older versions of Java where String.substring(...) created an object that shared the original String object's backing array. As you point out, that could lead to a memory leak; e.g. if the original string became unreachable and the substring didn't.