[PATCH] Cyclic reference preventing garbage collection in 1.9
2008-02-18 08:42:50 GMT
Hi all I have started to use SimPy 1.9 to simulate my PhD work, an economic resource allocation system. So far it has been straight forward, and a delight to use - my thanks :) However, I need to simulate some large systems, networks or traders with 50,000 nodes, and 50,000-100,000 new Processes (messages) being created every timestep, each Process running for about 6 timesteps on average. So about 450,000 currently active Processes at any given time. This is obviously fairly demanding in terms of memory, but I started hitting problems on much smaller runs (5000 nodes, 500-1000 Process/s). A bit or manual profiling of my code suggested that none of my Process objects were ever being deleted and garbage collected properly I had a look at Simulation.py, and noticed lines 588 and 594 created a circular reference to the Process objects, and thus prevent any Process object from being garbage collected; 588: what._rec=[at,self.sortpr,what,False] 594: what._rec=[at,-self.sortpr,what,False] A brief look over the code suggests the only reason that a Process needs a reference to its own queue record is for the _unpost method to correctly signal a Process to be cancelled. The quickfix patch below fixed the issue for me in terms of garbage collection, and my(Continue reading)
RSS Feed