Skip to content

Memory leak during import #90

@insani7y

Description

@insani7y

Long story short

I use aiofile to check health of consumers. Some file is being touched during consumer process and then in k8s liveness probe I compare modified time.
Unfortunately I noticed a memory leak that was caused by liveness probe.

Expected behavior

I expect no memory leaks :)

Actual behavior

There is one.

Steps to reproduce

Here code for reproduction:

# liveness_probe/__main__.py
import asyncio


async def liveness_probe() -> None:
    import aiofile

    aiofile


if __name__ == "__main__":
    asyncio.run(liveness_probe())

Aiofile should be imported inside function.

    livenessProbe:
      initialDelaySeconds: 30
      periodSeconds: 10
      timeoutSeconds: 10
      exec:
        command:
          - python
          - -m
          - liveness_probe

Just probe inside k8s Deployment.

Environment info

k8s version: 1.21.8
aiofile version: 3.8.0 - 3.8.8 (didn't check other)
python version: 3.11.3 - 3.11.6 (didn't check other)

I have been produced this problem with implementations:
✅ export CAIO_IMPL=linux
✅ export CAIO_IMPL=thread
✅ export CAIO_IMPL=python

Additional info

Here are graphs of the increase in the amount of memory consumed in pod:
photo_2023-10-12 16 33 10
photo_2023-10-12 16 33 07

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions