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

ProcessPool workers hold onto return value of last task in memory #79896

Closed
dchevell mannequin opened this issue Jan 11, 2019 · 2 comments
Closed

ProcessPool workers hold onto return value of last task in memory #79896

dchevell mannequin opened this issue Jan 11, 2019 · 2 comments
Labels
3.8 only security fixes stdlib Python modules in the Lib dir

Comments

@dchevell
Copy link
Mannequin

dchevell mannequin commented Jan 11, 2019

BPO 35715
Nosy @brianquinlan, @pitrou, @pablogsal, @dchevell
PRs
  • bpo-35715: Liberate return value of _process_worker #11514
  • bpo-35715: Liberate return value of _process_worker #11514
  • bpo-35715: Liberate return value of _process_worker #11514
  • bpo-35715: Liberate return value of _process_worker #11514
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-03-16.22:29:06.895>
    created_at = <Date 2019-01-11.08:36:21.237>
    labels = ['3.8', 'library']
    title = 'ProcessPool workers hold onto return value of last task in memory'
    updated_at = <Date 2019-03-16.22:29:06.894>
    user = 'https://github.com/dchevell'

    bugs.python.org fields:

    activity = <Date 2019-03-16.22:29:06.894>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-03-16.22:29:06.895>
    closer = 'pablogsal'
    components = ['Library (Lib)']
    creation = <Date 2019-01-11.08:36:21.237>
    creator = 'dchevell'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35715
    keywords = ['patch', 'patch', 'patch', 'patch']
    message_count = 2.0
    messages = ['333444', '338105']
    nosy_count = 4.0
    nosy_names = ['bquinlan', 'pitrou', 'pablogsal', 'dchevell']
    pr_nums = ['11514', '11514', '11514', '11514']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue35715'
    versions = ['Python 3.8']

    @dchevell
    Copy link
    Mannequin Author

    dchevell mannequin commented Jan 11, 2019

    ProcessPoolExecutor workers will hold onto the return value of their last task in memory until the next task is received. Since the return value has already been propagated to the parent process's Future or else effectively discarded, this is holding onto objects unnecessarily.

    Simple case to reproduce:

        import concurrent.futures
        import time
    
        executor = concurrent.futures.ProcessPoolExecutor(max_workers=1)
    
        def big_val():
            return [{1:1} for i in range(1, 1000000)]
    
        executor.submit(big_val)
    
        # Observe the memory usage of the process worker during the sleep interval
        time.sleep(10)

    This should be easily fixed by having the worker explicitly del r after calling _sendback_result as it already does this for call_item

    @dchevell dchevell mannequin added 3.8 only security fixes stdlib Python modules in the Lib dir labels Jan 11, 2019
    @pablogsal
    Copy link
    Member

    New changeset 962bdea by Pablo Galindo (Dave Chevell) in branch 'master':
    bpo-35715: Liberate return value of _process_worker (GH-11514)
    962bdea

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant