UXsim
UXsim copied to clipboard
Reduce memory usage
An UXsim simulation on my model took 4-6 GB for a few hundreds of thousands of vehicles, with vehicle logging off.
I profiled the memory in a small run, with as result:
[ Top 10 Memory Usage ]
.virtualenvs\Py312\src\uxsim\uxsim\uxsim.py:1431: size=1388 MiB, count=72, average=19.3 MiB
AppData\Local\Programs\Python\Python312\Lib\copy.py:71: size=90.7 MiB, count=962, average=96.6 KiB
.virtualenvs\Py312\src\uxsim\uxsim\uxsim.py:951: size=78.5 MiB, count=150008, average=549 B
.virtualenvs\Py312\src\uxsim\uxsim\uxsim.py:659: size=27.5 MiB, count=3272, average=8800 B
.virtualenvs\Py312\src\uxsim\uxsim\uxsim.py:620: size=27.5 MiB, count=3272, average=8800 B
The upper line indicates a huge amount of memory (1388 MiB, for a small run) is used here:
https://github.com/toruseo/UXsim/blob/ebdd6d4dc583a40c873d07b442a5ddd6dddeb322/uxsim/uxsim.py#L1411
I don't know that much about memory profiling, but this might be a leak or at least something we can optimise. I will try to get some more details.