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

Actor not released from worker memory, inducing memory leak #5610

Open
oarcher opened this issue Dec 17, 2021 · 2 comments
Open

Actor not released from worker memory, inducing memory leak #5610

oarcher opened this issue Dec 17, 2021 · 2 comments

Comments

@oarcher
Copy link

oarcher commented Dec 17, 2021

I have a class WorkWithActor that instantiate an actor, and work with it.
The actor survive to de deletion of the WorkWithActor instance, and it induce some memory leaks on the workers

I expect that the actor is removed from the worker when the future no longer exists

Minimal Complete Verifiable Example:

from dask.distributed import Client, worker_client


class Actor:

    def __init__(self, n):
        self.n = n
        self.memory = bytearray(32000000)  # consume some memory

    def do_something(self):
        return -self.n

    def __del__(self):
        print('__del__ Actor')  # not reached


class WorkWithActor:
    def __init__(self, n):
        with worker_client() as client:
            self._future = client.submit(Actor, n, actor=True)
            self._actor = self._future.result()

    def work(self):
        return self._actor.do_something()

    def __del__(self):
        print('__del__ WorkWithActor') # reached


def batch(n):
    work_with_actor = WorkWithActor(n)
    return work_with_actor.work()

if __name__ == "__main__":
    client = Client()
    print(client.dashboard_link)

    results = client.map(batch, range(1000))

Environment:

  • Dask version: 2021.12.0
  • Python version: 3.9.7
  • Operating System: linux
  • Install method (conda, pip, source): conda-forge
@oarcher
Copy link
Author

oarcher commented Dec 17, 2021

It might be related to #4937 ?

@martindurant in #4937 (comment) says:

Is there a test showing that an actor is not currently cleaned up?

oarcher added a commit to oarcher/xsar that referenced this issue Dec 18, 2021
Make Sentinel1Meta serializable with __reduce__
Better use of rioxarray
Disabled 'SAFE' GDAL driver
Disabled xml_parser cache,  while  dask/distributed#5610 is not solved
@holdenk
Copy link

holdenk commented May 25, 2022

Interestingly re-ran this on Dask 2022.5.1 with Python 3.8 and it seems that the inner actor is also being cleaned up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants