The issue occurred in the Loading Rack component of the AnyLogic-based Petroleum Refining Library (PRL), which models the loading of finished petroleum products into railcars at refinery
tank farms. This allows the model to account for constraints on
finished-product dispatch and pumping capacity, including limitations on how quickly products can be transferred from storage to rail transport.
Loading Rack uses a
database-defined train schedule. When the original schedule is exhausted, the scheduling algorithm automatically extends it by repeating the existing arrival pattern. This allows the model to simulate long operational periods without requiring an excessively large input schedule. The problem became visible only when this schedule extension was used for long-running simulations, where new railcar objects continued to be generated over time. The investigation revealed that every newly generated railcar was being registered in an internal object registry. These references remained even after the railcars were no longer needed by the simulation, causing Java object retention and preventing garbage collection. As the schedule was extended, the registry continued to grow, keeping tens of thousands of obsolete objects reachable as the simulation progressed. The resulting memory growth gradually increased the computational overhead of the simulation, causing each subsequent month to take longer to calculate.