Iron's Spells 'n Spellbooks

Iron's Spells 'n Spellbooks

18M Downloads

[Performance] Memory Leak of entities

pietro-lopes opened this issue ยท 1 comments

commented

Observed behaviour

Follow up of #651 as it is the same issue.
It is leaking some discarded projectiles in this map.

maybe change this to consider a logic when Entity is null and remove from the map? (need to use iterator to not throw CME)

for (Map.Entry<UUID, ArrayList<Projectile>> entityToTrackedProjectiles : GuidingBoltManager.INSTANCE.trackedEntities.entrySet()) {
var entity = serverLevel.getEntity(entityToTrackedProjectiles.getKey());
if (entity != null) {
if (Math.abs(entity.getX() - projectile.getX()) > searchRange || Math.abs(entity.getY() - projectile.getY()) > searchRange || Math.abs(entity.getZ() - projectile.getZ()) > searchRange) {
continue;
}
float homeRadius = 3.5f + Math.min(entity.getBbWidth() * .5f, 2);
if (entity.getBoundingBox().inflate(homeRadius).contains(start) || Utils.checkEntityIntersecting(entity, start, end, homeRadius).getType() == HitResult.Type.ENTITY) {
updateTrackedProjectiles(entityToTrackedProjectiles.getValue(), projectile);
toSync.computeIfAbsent(entity, (key) -> new ArrayList<>()).add(projectile);
break;
}
}
}

image

Expected behaviour

Not leak

Steps to reproduce

This was a heapdump from a server.

Server Type

Dedicated Server

Crashlog

No response

Iron's Spells N Spellbooks version

3.8.4

Forge version

neoforge 21.1.81

Other mods

ATM10 Modpack

Crashlog Check

  • I understand if this is a crashbug and I did not attach a crashlog, this will not be handled
commented

fixed in 3.8.6