{"comment":{"created_at":"2011-10-11T12:39:12Z","body":"Suprising for JSE Developers where Strings are copied when needed. ","updated_at":"2011-10-11T12:39:12Z","url":"https://api.github.com/repos/cgeo/c-geo-opensource/issues/comments/2360871","id":2360871,"user":{"avatar_url":"https://secure.gravatar.com/avatar/815875a304a0bc0a38f51759ad840e20?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/Portree-Kid","id":999932,"login":"Portree-Kid"}},"action":"created","issue":{"number":654,"created_at":"2011-10-10T20:20:53Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"In `getMatch()`, we try to avoid keeping large strings in memory (such as a whole web page) when we only need a small part by using an explicit `String` constructor, in a way similar to\r\n\r\n```java\r\n    final String newString = new String(oldString);\r\n```\r\n\r\nHowever, when looking at Android sources (through my CyanogenMod checked out copy), I noticed that this constructor is implemented as\r\n\r\n```java\r\n    public String(String string) {\r\n        value = string.value;\r\n        offset = string.offset;\r\n        count = string.count;\r\n    }\r\n```\r\n\r\nwhich defeats the purpose, `value` being the real storage.\r\n\r\nTo avoid keeping long strings around, if this is needed, we may have to use something like\r\n\r\n```java\r\n   final String newString = new String(oldString.getBytes())\r\n```\r\n\r\nComments, thoughts?","comments":9,"title":"Large strings may be kept too long","updated_at":"2011-10-11T12:39:12Z","url":"https://api.github.com/repos/cgeo/c-geo-opensource/issues/654","id":1867733,"assignee":null,"milestone":null,"closed_at":"2011-10-11T11:50:08Z","user":{"avatar_url":"https://secure.gravatar.com/avatar/6e6d5c89985a1976429d28f117eb5137?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/samueltardieu","id":44656,"login":"samueltardieu"},"html_url":"https://github.com/cgeo/c-geo-opensource/issues/654","labels":[{"name":"feedback","url":"https://api.github.com/repos/cgeo/c-geo-opensource/labels/feedback","color":"FAB028"}],"state":"closed"},"legacy":{"issue_id":1867733,"comment_id":2360871}}