logo separator

[mkgmap-dev] Patch to reduce memory usage by interning strings.

From Chris Miller chris_overseas at hotmail.com on Thu Apr 1 14:11:51 BST 2010

> I think the point that Chris brought up applies mostly in cases where
> there is a lot of contended access between threads.  If that is the
> case then it won't matter much for us as reading the input files is
> currently single threaded.

It's true, the biggest gains by far in the approach I was pointing out are 
when you have heavy concurrent access. I just saw Scott mention his code 
wasn't threadsafe so figured a multithreaded solution was desirable. However 
String.intern() can still be expensive even in a single-threaded environment. 
Replacing String.intern() with something simple like  if (!hashSet.contains()) 
hashSet.add(str)  should be roughly 2x quicker. Probably negligible in the 
grand scheme of things :)

Chris






More information about the mkgmap-dev mailing list