In analyzing heap memory usage, it was noticed that long[]
was a serious contender...
In tracing it back, it was found that BitSet}}s used for Carving Masks were the heaviest user, stored as a reference from {{ProtoChunk
, which was linked to the ChunkHolder
.
The ChunkHolder
is holding a ref from the status future cache.
This is due to the fact that during Chunk Saving, the carving masks are saved regardless of chunk status, so saving creates the 65k BitSet}}s and saves them, even at statuses like {{StructureStart
which we have TONS of....
Then when that ProtoChunk
is loaded again, those 65k {{BitSet}}s are loaded into memory and kept around in the cache even when that chunk isn't promoting to FULL.
Fix is pretty simple, don't write CarvingMasks unless they've actually been generated when saving.
for (int l = 0; l < k; ++l) {
WorldGenStage.Features worldgenstage_features = aworldgenstage_features[l];
// Paper start - don't create carving mask bitsets if not even at that chunk status yet
BitSet mask = protochunk.getCarvingMaskIfSet(worldgenstage_features);
if (mask != null) {
nbttagcompound3.setByteArray(worldgenstage_features.toString(), mask.toByteArray());
}
// Paper end
}
Comments 0
No comments.