Skip to content

EntityTracker blacklist grows unbounded — memory leak and stale entries #18

Description

@RiaDev1

Description

EntityTracker maintains a blacklist (entityBlacklist) for entities/items that are unreachable or despawned. This blacklist has NO cleanup mechanism — entries are added but never removed when entities despawn or the player moves to a different area.

Root Cause

In EntityTracker:

// entityBlacklist.unreachable(entity) is used to skip entities
// but entries are never cleaned up after entity despawns

This leads to:

  1. Memory leak: Over long play sessions, the blacklist accumulates thousands of stale entries
  2. False negatives: Items that become reachable again (e.g. after moving closer) remain blacklisted
  3. Performance degradation: Every entity lookup iterates through the growing blacklist

Expected Behavior

Blacklist entries should be periodically cleaned up, and entries should expire on:

  • Entity despawn
  • Player moving to a different dimension
  • Distance exceeding a threshold
  • Time-based expiration (e.g. 60 seconds)

Suggested Fix

  1. Add a timestamp to each blacklist entry
  2. Clean up entries older than e.g. 60 seconds
  3. Clean up entries for entities that no longer exist in the world
  4. Cap the maximum blacklist size

Related

  • src/main/java/adris/altoclef/trackers/EntityTracker.java
  • entityBlacklist field

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions