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
Memory leak when driving simulations with a VPI plugin. #1226
Comments
I will investigate. The memory handling in VPI is not clear. In all examples you can find in books or on the internet, vpi_free is rarely called. |
And thank you for your standalone reproducer. That's very useful. |
Thank you :)! |
@tgingold PLI_INT32 vpi_free_object(vpiHandle handle)/* handle for an object */ Frees memory allocated by the PLI for the specified handle. Returns 1 if successful, and I tried to use it on the handle of vpi_register_cb but it crashes the ghdl execution :P .. |
Can you post the code which use vpi_free_object ? That could be useful too!
|
From Sutherland's When a simulation callback is registered, the handle for the callback will persist the callback_handle = vpi_register_cb(&cb_data_s);
vpi_free_object(callback_handle); /* free callback handle */ Freeing the callback handle immediately after registering the callback is registered Do not call vpi_free_object () on a callback handle if the callback has been So I tried to wrap There are some examples in The Verilog PLI Handbook that use vpi_free_object () to delete callback handles, but the way they do that is not anything more than the two lines of code above |
Description
In simulations where events are scheduled by a VPI plugin using vpi_register_cb, even if no wave files are specified, the memory usage increases every time a new callback is registered. If to many calls are done, the system ram and cache is completely filled and the process is killed. In my machine such amount is around to ~5GB of ram.
Expected behavior
I would have expected that a fixed amount of memory is needed in a simulation if the wave traces have not to be saved
How to reproduce?
To reproduce the issue the following vpi plugin is given:
The VPI plugin generate a chain of callbacks that repeats
cbAfterDelay -> cbReadWriteSynch -> cbAfterDelay -> cbReadOnlySynch one billion times
A 'dummy' vhdl source(any other vhdl file can be used):
A script file to execute the simulation
to run the simulation use
Context
Memory usage report example
Notes
This was discovered working on SpinalHDL/SpinalHDL#146
The text was updated successfully, but these errors were encountered: