8000 Release memory when a deamon exits by jeff4747 · Pull Request #953 · nolar/kopf · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Release memory when a deamon exits #953

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

Merged
merged 3 commits into from
Feb 7, 2023
Merged
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
14 changes: 14 additions & 0 deletions kopf/_core/engines/daemons.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,20 @@ async def _runner(
if stopper.reason is None:
memory.forever_stopped.add(handler.id)

# If this daemon is never going to be called again, we can release the
# live_fresh_body to save some memory.
if handler.id in memory.forever_stopped:
# If any other running daemon is referencing this Kubernetes
# resource, we can't free it
can_free = True
this_daemon = daemons[handler.id]
for running_daemon in memory.running_daemons.values():
if running_daemon is not this_daemon:
can_free = False
break
if can_free:
memory.live_fresh_body = None

# Save the memory by not remembering the exited daemons (they may be never re-spawned).
del daemons[handler.id]

Expand Down
0