From 061e1e0f5ae1c7c19a84c80e60a3643556b25fc2 Mon Sep 17 00:00:00 2001 From: rsudev Date: Thu, 3 Jan 2013 13:11:52 +0100 Subject: Fixes #2319, Out of memory error with OSM and Google Maps There were still some places in the GCParser that directly assigned regex matcher results to cache properties, thereby keeping the whole page string referenced. --- main/src/cgeo/geocaching/connector/gc/GCParser.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'main/src') diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java index 7fc06c1..9edc34f 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCParser.java +++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java @@ -536,15 +536,19 @@ public abstract class GCParser { while (matcherSpoilersInside.find()) { // the original spoiler URL (include .../display/... contains a low-resolution image // if we shorten the URL we get the original-resolution image - String url = matcherSpoilersInside.group(1).replace("/display", ""); + // + // Create a new string to avoid referencing the whole page though the matcher (@see BaseUtils.getMatch()) + String url = new String(matcherSpoilersInside.group(1).replace("/display", "")); String title = null; if (matcherSpoilersInside.group(3) != null) { - title = matcherSpoilersInside.group(3); + // Create a new string to avoid referencing the whole page though the matcher (@see BaseUtils.getMatch()) + title = new String(matcherSpoilersInside.group(3)); } String description = null; if (matcherSpoilersInside.group(4) != null) { - description = matcherSpoilersInside.group(4); + // Create a new string to avoid referencing the whole page though the matcher (@see BaseUtils.getMatch()) + description = new String(matcherSpoilersInside.group(4)); } cache.addSpoiler(new cgImage(url, title, description)); } @@ -572,8 +576,10 @@ public abstract class GCParser { while (matcherInventoryInside.find()) { if (matcherInventoryInside.groupCount() > 0) { final cgTrackable inventoryItem = new cgTrackable(); - inventoryItem.setGuid(matcherInventoryInside.group(1)); - inventoryItem.setName(matcherInventoryInside.group(2)); + // Create a new string to avoid referencing the whole page though the matcher (@see BaseUtils.getMatch()) + inventoryItem.setGuid(new String(matcherInventoryInside.group(1))); + // Create a new string to avoid referencing the whole page though the matcher (@see BaseUtils.getMatch()) + inventoryItem.setName(new String(matcherInventoryInside.group(2))); cache.getInventory().add(inventoryItem); cache.setInventoryItems(cache.getInventoryItems() + 1); -- cgit v1.1