This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients aeros, asvetlov, benjamin.peterson, vstinner, yselivanov
Date 2019-11-14.11:17:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1573730255.7.0.659244975111.issue38591@roundup.psfhosted.org>
In-reply-to
Content
I measured the RSS memory per thread: it's around 13.2 kB/thread. Oh, that's way lower than what I expected.

Script:

# 10: 9636 kB => 9756 kB: +12 kB/thread
# 100: 9476 kB = 10796 kB: +13.2 kB/thread
# 1000: 9552 kB = 22776 kB: +13.2 kB/thread

import os
import threading

def display_rss():
    os.system(f"grep ^VmRSS /proc/{os.getpid()}/status")

def wait(event):
    event.wait()

class Thread(threading.Thread):
    def __init__(self):
        super().__init__()
        self.stop_event = threading.Event()
        self.started_event = threading.Event()

    def run(self):
        self.started_event.set()
        self.stop_event.wait()

    def stop(self):
        self.stop_event.set()
        self.join()

def main():
    nthread = 1000
    display_rss()
    threads = [Thread() for i in range(nthread)]
    for thread in threads:
        thread.start()
    for thread in threads:
        thread.started_event.wait()
    display_rss()
    for thread in threads:
        thread.stop()

main()
History
Date User Action Args
2019-11-14 11:17:35vstinnersetrecipients: + vstinner, benjamin.peterson, asvetlov, yselivanov, aeros
2019-11-14 11:17:35vstinnersetmessageid: <1573730255.7.0.659244975111.issue38591@roundup.psfhosted.org>
2019-11-14 11:17:35vstinnerlinkissue38591 messages
2019-11-14 11:17:35vstinnercreate