cgeo/c-geo-opensource — Issue #654: Large strings may be kept too long
Author: samueltardieu
Created: 2011-10-10 20:20:53+00:00
State: open

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

```java
final String newString = new String(oldString);
```

However, when looking at Android sources (through my CyanogenMod checked out copy), I noticed that this constructor is implemented as

```java
public String(String string) {
value = string.value;
offset = string.offset;
count = string.count;
}
```

which defeats the purpose, `value` being the real storage.

To avoid keeping long strings around, if this is needed, we may have to use something like

```java
final String newString = new String(oldString.getBytes())
```

Comments, thoughts?