FerriteCore ((Neo)Forge)

FerriteCore ((Neo)Forge)

96M Downloads

Regression in FastMap memory usage for blocks with no properties

embeddedt opened this issue ยท 1 comments

commented

The change made in 130f29c (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 the Object2IntOpenHashMap is designed to be mutable, and likely has a higher memory footprint than the ImmutableMap (I have not measured this, though).

commented

Related question: any reason not to use ImmutableList.copyOf(valuesList) here to avoid storing the extra ArrayList and unmodifiable wrapper objects?

this.valueMatrix = Collections.unmodifiableList(valuesList);