Request for Review : CR#6924259: Remove String.count/String.offset

wangsheng.0376 wangsheng.0376 at
Fri Apr 12 13:50:21 UTC 2013

hi, all,

I agree with you to remove offset, today when I run following code in jdk7(sorry I forget the detail version), my code is like this:

Pattern pattern = Pattern.compile(regex);

Matcher matcher = pattern.match(content);

while (matcher.find()) {

     String link =;

     set.add(link);// set is a HashSet type


after I running for some time, I found that the 'set' object has memory leak, I found though 'link' is a part of 'content', but the value field in link variable is same as 'content' value field, difference is that the link offset field is not zero.

So that mean the set(HashSet) is not store the 'link', it store the 'content' value field, it will cause the memory leak problem, So I am very happy to reomve the offset field.

Best Regards

More information about the core-libs-dev mailing list