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

Free the loaded library at shutdown #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/JABWrapper/jab_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
create_unicode_buffer
)

from _ctypes import FreeLibrary

from typing import Callable, List, Tuple

from JABWrapper.jab_types import (
Expand Down Expand Up @@ -195,9 +197,14 @@ def _init(self) -> None:
self._context_callbacks: dict[str, List[Callable[[JavaObject], None]]] = dict()

def shutdown(self):
# Call at the end to execution to free memory and unload the
# windows wrapper.dll
self._context_callbacks = dict()
if not self.ignore_callbacks:
self._remove_callbacks()
if self._wab and self._wab._handle:
FreeLibrary(self._wab._handle)
del self._wab

def _define_functions(self) -> None:
# void Windows_run()
Expand Down