Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

concurrent.futures.ThreadPoolExecutor does not free memory when shutdown #98467

Open
Labels
stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error
@eMeena

Description

@eMeena

Bug report

Memory allocated in threads is never freed when using a ThreadPoolExecutor. The expected behavior is that when the executor is shut down, all memory allocated in its threads should be freed. The below code demonstrates this leak in that the the memory usage before allocating memory in threads is significantly less than after.

fromconcurrent.futuresimportThreadPoolExecutor,as_completedimportresourcedefprocess_user(x):returnbytearray(10000000)print('Before',resource.getrusage(resource.RUSAGE_SELF).ru_maxrss/1024,'MB')defleak_memory():withThreadPoolExecutor(max_workers=20)asexecutor:futures= [executor.submit(process_user,i)foriinrange(100)]forfutureinas_completed(futures):cur=resource.getrusage(resource.RUSAGE_SELF).ru_maxrss/1024print('Step',cur)leak_memory()print('After',resource.getrusage(resource.RUSAGE_SELF).ru_maxrss/1024,'MB')

Your environment

Python 3.9.x/3.10.x. Mac os and debian.

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp