-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
While analyzing memory usage in All The Mods 10 for FerriteCore (total heap: 4.5 GB), I noticed that owolibs DerivedComponentMap feature increases memory usage by about 350 MB. I think the root cause is that the logic is applied to all stacks (about 2.75M instances in memory), rather than just those for items that implement a nontrivial deriveStackComponents (i.e. a very small fraction).
The additional memory usage has two separate causes:
- Calling
PatchedDataComponentMap::applyPatch/ComponentMapImpl::setChangeson a newly initialized component map will callensureMapOwnership, even if the argument is an empty map as it is here. This causes the singleton returned byReference2ObjectMaps.emptyMapto be replaced with a newReference2ObjectArrayMap, which uses 72 extra bytes per stack. Since nearly all stacks in memory have empty patches, this means an extra memory usage of72 * 2.75M = 198 MB. I implemented a more general fix for memory usage from these empty maps in the latest release for FerriteCore, but I think it would still be good if this was fixed on your end as well. - Even when this is resolved, the feature results in noticeably increased memory usage. This usage is simply from the presence of two new object for each
ItemStackinstance, oneDerivedComponentMap(24 bytes shallow) and thePatchedDataComponentMap/ComponentMapImplstored in it (32 bytes shallow). This works out to56 * 2.75M = 154 MBof additional memory usage.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels