A simple fix is probably to have a static, empty Object2IntOpenHashMap instance that is used if the block contains no properties. However I am suspicious the change might still regress memory usage in the case of 1 or 2 properties as the Object2IntOpenHashMap is designed to be mutable, and likely has a higher memory footprint than the ImmutableMap (I have not measured this, though).
The change made in https://github.com/malte0811/FerriteCore/commit/130f29ca7428dced035dded4020abb419822cd06 (since 1.18) causes an
Object2IntOpenHashMap
to be allocated for every block, including ones with no properties. In a test scenario with 1 million property-less blocks, this seems to be using ~350MB of memory.A simple fix is probably to have a static, empty
Object2IntOpenHashMap
instance that is used if the block contains no properties. However I am suspicious the change might still regress memory usage in the case of 1 or 2 properties as theObject2IntOpenHashMap
is designed to be mutable, and likely has a higher memory footprint than theImmutableMap
(I have not measured this, though).