Acorn MainProgram does tons of completely unnecessary new TreeMap, TreeMap.entrySet and Semaphore allocations
When heavy operations are being performed into the database, Acorn MainProgram
class tends to go into busy looping mode.
The main loop however is constructed in too naive fashion without checking anything. On every iteration of the loop it always runs new TreeMap()
regardless of whether the previous loop did absolutely nothing with the TreeMap it created.
Also, runUpdates(TreeMap) does new Semaphore
and TreeMap.entrySet()
creating an unnecessary iterator instance when the map is totally empty. When busy looping, this starts to show up in JMC profiling as totally useless memory/cpu pressure overhead.
A very simple and backportable fix.