-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce memory usage #143
Comments
The The bigger problem is that it doesn't get recycled / collected however, but just keeps growing: This is "just" two hours of simulation, taking already 1GB. |
I got time for quick comments. Thanks for investigating. I didnt notice this issue. I agree that this must be solved. But it is very weird that |
Even with the PRs applied, there's still definitely a memory leak in UXsim somewhere. When running multiple scenarios sequentially, the UXsim World (and probably some of its components) don't get garbage collected properly.
|
Now I remember that each vehicle holds its own Adding an option to deleting it after vehicle's trip is considerable |
Use new reduce_memory_delete_vehicle_route_pref=True argument when initializing the UXsim world to reduce the memory usage. Without this, each vehicle holds its own route_pref to represent possibly heterogeneous route choice. In a large network, its total size may become huge. This deletes it after each vehicle's trip done. See: - toruseo/UXsim#143 (comment) - toruseo/UXsim#149 Rebased the time_bin_mem_opt branch: https://github.com/EwoutH/uxsim@time_bin_mem_opt#egg=uxsim In-place updates to route_pref (#146) is now also included.
Thanks! I'm running more simulations tonight, I enabled it, curious if / how much it will help. Another option that would be useful for me is just deleting the vehicle altogether after its finished. Especially for longer simulations that should help memory from inflating. Especially if you don't need data from Vehicle objects or have already saved them while/before finishing. With #130 Could just be another boolean switch like |
I think deleting vehicle is too drastic (we will need to add a lot of exception-catching codes to fully support that function), and I dont want to add it as a default function. This is a traffic simulator after all; deleting traffic is not an option. Maybe it can be added to user-side codes by using |
Regarding this and related issues and PRs on the performance improvements, I think most of the feasible options have been implemented. So, I am closing them. Of course, I understand that the current version is far from perfect and there is a lot of room for improvement. Feel free to re-open them or propose new ideas. Thanks for the suggestions and contributions! |
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:
The upper line indicates a huge amount of memory (1388 MiB, for a small run) is used here:
UXsim/uxsim/uxsim.py
Line 1411 in ebdd6d4
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.
The text was updated successfully, but these errors were encountered: