[boskid][2.0.28] Memory leak with overlapping poles with supply-area-distance=64

This subforum contains all the issues which we already resolved.
robot256
Smart Inserter
Smart Inserter
Posts: 1032
Joined: Sun Mar 17, 2019 1:52 am
Contact:

[boskid][2.0.28] Memory leak with overlapping poles with supply-area-distance=64

Post by robot256 »

The attached mod has only one line:

Code: Select all

data.raw["electric-pole"]["medium-electric-pole"].supply_area_distance = 64;
The attached save is vanilla plus the attached mod.

Repro steps:
1. Load the provided game with the provided mod in vanilla 2.0.28
2. Hover mouse over the combinator in the center of screen, and press R many times (on Windows 11 with 32GB or RAM, at least 20 times).
3. If the memory leak is triggered, then memory usage will start to grow with each press of R. E.g., 2GB->3.5GB->5GB->9GB->12GB->18GB. Each press will take longer to process before game execution resumes.

Info:
The combinator being rotated is powered by 4 separated power poles all drawing power from the same electric energy interface. I'm sure the memory leak is in the "which electric network am I powered by now?" code. It is also highly dependent on the exact configuration of poles and networks. Using fewer poles or poles in different locations, or just moving the poles around can cause the leak to no longer trigger.

It's also clearly in the ephemeral game state. Rotating 15 times, saving the game, and loading it again resets the effect and another 20 rotations are needed before memory-leak-induced lag happens again.
Attachments
CPU-v2-repro-2_minimal.zip
(9.1 MiB) Downloaded 11 times
ExtremePoleCoverage_0.0.2.zip
(884 Bytes) Downloaded 10 times
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3362
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [boskid][2.0.28] Memory leak with overlapping poles with supply-area-distance=64

Post by boskid »

Thanks for the report. Issue is now fixed for 2.0.29.

All the reproduction steps, mod, save file were really helpful in quickly finding where the issue was. It happened to be an issue with one of our custom vector class that was reserving more and more memory when inserting items in the middle of a vector even when there was no need for the growth to happen. That perfectly matches with your observation about "ephemeral" state since we never save capacity of vectors and so after save-load the capacity would shrink to what is actually needed.
robot256
Smart Inserter
Smart Inserter
Posts: 1032
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: [boskid][2.0.28] Memory leak with overlapping poles with supply-area-distance=64

Post by robot256 »

Happy to help! The repro was given to me by a friend to confirm and post. He'll be glad to have the bug fixed!
Post Reply

Return to “Resolved Problems and Bugs”