Skip to content
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

Ability to unload PyGeNN models #581

Merged
merged 1 commit into from
May 15, 2023
Merged

Ability to unload PyGeNN models #581

merged 1 commit into from
May 15, 2023

Conversation

neworderofjamie
Copy link
Contributor

PyGeNN GeNNModel objects wrap both a ModelSpec holding the model description and a SharedLibraryModel for loading the dynamic library created from the generated code and executing it. This PR lets you 'unload' the SharedLibraryModel component, freeing memory but allowing it to be easily re-loaded if required. This entails:

  • In PyGeNN, resetting all views to None to prevent freed memory being accessed
  • Adding a close method to SharedLibraryModel which sets all pointers to variables etc to nullptr, empties the cache used to speed up access to functions and unloads the shared library.

Copy link
Member

@tnowotny tnowotny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahem, sorry for the delay. This looks reasonable though I do not have the overview of whether everything is cleaned up that needs cleaning up. What would be a good test for this?

@neworderofjamie
Copy link
Contributor Author

Will defer adding new tests until GeNN 5 when I reimplement feature tests in Python - raised #587 to remind me

@neworderofjamie neworderofjamie merged commit cf51800 into master May 15, 2023
@neworderofjamie neworderofjamie deleted the pygenn_unload branch May 15, 2023 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants