Skip to content

Memory leak with enabled rendering #6

@koelnconcert

Description

@koelnconcert

When pipe rendering is enabled we noticed a memory leak in our world leading to very laggy game play and ultimately to out-of-memory crashes.

In a small local test setup (sending items in a circle with 64 pipes and a chest) we could see millions of TimedPipePath objects in NetworkInformation.inverseTrackedPaths after just a couple of minutes.

Looks like when data from the server is deserialized by the client, the resources in a PipeEntity are reset but the NetworkInformation is not in AbstractPipeEntity.java:

private void readQueueFromTag(NbtCompound tag) {
    NbtList list = tag.getList("queue", 10);
    resources = new HashSet<>();
    for (int i = 0; i < list.size(); i++) {
        TimedPipePath<C> result = TimedPipePath.fromTag(list.getCompound(i), getResourceHandler());
        networkInformation.addTrackedPath(result);
        resources.add(result);
    }
}

Clearing the two maps in NetworkInformation in the above method solves the problem.

This was detected for the current branch 1.19.

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