[mkgmap-dev] [PATCH v1] Reduce memory footprint of tags
From WanMil wmgcnfg at web.de on Mon Feb 8 18:46:15 GMT 2010
The discussions around "Commit: r1566: Drop all tags from the osm file that are not used" inspired me to address the memory footprints of the tags. The patch reduces the memory footprint by using the String.intern() method. This ensures that the String "highway" exists only once when stored as tag. Additionally the values of the most common tags with a limited number of different values are also interned. (It makes sense to intern the value of a highway tag but it does not make sense to intern the value of a name tag because the share rate of the name tag values is too low). This all might sound embarrasing but the String objects that are returned from the XML reader are not interned. You can test this easily by exchanging the put method in class tag: public String put(String key, String value) { if ("highway".equals(key) && "highway" != key) { log.error("Tag is not interned"); } ensureSpace(); Integer ind = keyPos(key); if (ind == null) assert false : "keyPos(" + key + ") returns null - size = " + size + ", capacity = " + capacity; keys[ind] = key; String old = values[ind]; if (old == null) size++; values[ind] = value; return old; } You will see lots of "Tag is not interned" errors. I have seen memory reductions of > 10%. Please test this patch against your well known tiles. It would be perfect if someone has a tile and knows its minimum memory requirement for mkgmap. This patch should lower it. WanMil -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: mem_tag_reduce_v1.patch Url: http://lists.mkgmap.org.uk/pipermail/mkgmap-dev/attachments/20100208/6e95ed5c/attachment.pl
- Previous message: [mkgmap-dev] Commit: r1566: Drop all tags from the osm file that are not used
- Next message: [mkgmap-dev] [PATCH v1] Reduce memory footprint of tags
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the mkgmap-dev mailing list