
Hi, I noticed that each ExtTypeAttributes instance allocates a DecimalFormat instance. This requires ~700 Bytes, but it seems that it is only used in rare cases. With the style that I am using for testing, I see > 200.000 instances of the ExtTypeAttributes class, so 140Mb are probably wasted. Attached small patch allocates the instance only when needed. Any objections? Gerd ExtTypeAttributes.patch <http://gis.19327.n5.nabble.com/file/n5743637/ExtTypeAttributes.patch> -- View this message in context: http://gis.19327.n5.nabble.com/Optimization-for-ExtTypeAttributes-tp5743637.... Sent from the Mkgmap Development mailing list archive at Nabble.com.

tried out the patch, it doesn't save much for me (around 0.5% in mapsize for Austria), but better save something than not if it doesn't matter. On 09.01.2013 18:04, GerdP wrote:
Hi,
I noticed that each ExtTypeAttributes instance allocates a DecimalFormat instance. This requires ~700 Bytes, but it seems that it is only used in rare cases. With the style that I am using for testing, I see > 200.000 instances of the ExtTypeAttributes class, so 140Mb are probably wasted.
Attached small patch allocates the instance only when needed. Any objections?
Gerd
ExtTypeAttributes.patch <http://gis.19327.n5.nabble.com/file/n5743637/ExtTypeAttributes.patch>
-- View this message in context: http://gis.19327.n5.nabble.com/Optimization-for-ExtTypeAttributes-tp5743637.... Sent from the Mkgmap Development mailing list archive at Nabble.com. _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://lists.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
-- keep on biking and discovering new trails Felix openmtbmap.org & www.velomap.org

Hi Felix, Felix Hartmann-2 wrote
tried out the patch, it doesn't save much for me (around 0.5% in mapsize for Austria), but better save something than not if it doesn't matter. On 09.01.2013 18:04, GerdP wrote:
thanks for trying. I am a bit confused: The patch should not change the output in any way, it just just descrease peak memory usage. What do you mean with mapsize? ciao, Gerd -- View this message in context: http://gis.19327.n5.nabble.com/Optimization-for-ExtTypeAttributes-tp5743637p... Sent from the Mkgmap Development mailing list archive at Nabble.com.

Oh, well maybe that was due to the fact, that I changed min-size-polygon from 14 to 18 at the same time... On 10.01.2013 17:11, GerdP wrote:
Hi Felix,
Felix Hartmann-2 wrote
tried out the patch, it doesn't save much for me (around 0.5% in mapsize for Austria), but better save something than not if it doesn't matter. On 09.01.2013 18:04, GerdP wrote: thanks for trying. I am a bit confused: The patch should not change the output in any way, it just just descrease peak memory usage.
What do you mean with mapsize?
ciao, Gerd
-- View this message in context: http://gis.19327.n5.nabble.com/Optimization-for-ExtTypeAttributes-tp5743637p... Sent from the Mkgmap Development mailing list archive at Nabble.com. _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://lists.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
-- keep on biking and discovering new trails Felix openmtbmap.org & www.velomap.org

Hi,
I noticed that each ExtTypeAttributes instance allocates a DecimalFormat instance. This requires ~700 Bytes, but it seems that it is only used in rare cases. With the style that I am using for testing, I see > 200.000 instances of the ExtTypeAttributes class, so 140Mb are probably wasted.
Attached small patch allocates the instance only when needed. Any objections?
Gerd
ExtTypeAttributes.patch <http://gis.19327.n5.nabble.com/file/n5743637/ExtTypeAttributes.patch>
Sounds good too. I don't see any problem to apply this patch. WanMil

Hi,
I noticed that each ExtTypeAttributes instance allocates a DecimalFormat instance. This requires ~700 Bytes, but it seems that it is only used in rare cases. With the style that I am using for testing, I see > 200.000 instances of the ExtTypeAttributes class, so 140Mb are probably wasted.
Attached small patch allocates the instance only when needed. Any objections?
Gerd
ExtTypeAttributes.patch <http://gis.19327.n5.nabble.com/file/n5743637/ExtTypeAttributes.patch>
Sounds good too. I don't see any problem to apply this patch.
WanMil
Gerd, I think there is an issue with the DecimalFormat which has nothing to do with your patch. The DecimalFormat is instantiated without any locale which means java uses the default locale. So if you are english everything is fine but if you are german your numbers are formatted and parsed with the "," as decimal separator. I don't know what locale is the best to use but something like new DecimalFormat("0.0#", DecimalFormatSymbols.getInstance(Locale.US)); should work. What do you think? WanMil

WanMil wrote
So if you are english everything is fine but if you are german your numbers are formatted and parsed with the "," as decimal separator.
I don't know what locale is the best to use but something like new DecimalFormat("0.0#", DecimalFormatSymbols.getInstance(Locale.US)); should work. What do you think?
Sounds reasonable. I did never read the details about this class. I only wondered why Double.valueOf() is not good enough to parse a string. Gerd -- View this message in context: http://gis.19327.n5.nabble.com/Optimization-for-ExtTypeAttributes-tp5743637p... Sent from the Mkgmap Development mailing list archive at Nabble.com.

WanMil wrote
So if you are english everything is fine but if you are german your numbers are formatted and parsed with the "," as decimal separator.
I don't know what locale is the best to use but something like new DecimalFormat("0.0#", DecimalFormatSymbols.getInstance(Locale.US)); should work. What do you think?
Sounds reasonable. I did never read the details about this class. I only wondered why Double.valueOf() is not good enough to parse a string.
It is possible that the value also contains a unit like "2.45ft". Double.valueOf() fails here. WanMil
participants (4)
-
Felix Hartmann
-
GerdP
-
Steve Ratcliffe
-
WanMil