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 Tianshu Gao
Recipients Tianshu Gao, asvetlov, yselivanov
Date 2019-08-21.20:55:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1566420903.63.0.857548145971.issue37909@roundup.psfhosted.org>
In-reply-to
Content
This is very similar to issue35715. But this is happen for thread.

After the func in thread finished, the memory is still hold and accumulate.

import asyncio
import time
import concurrent
import threading

loop = asyncio.get_event_loop()

def prepare_a_giant_list():
    m = []
    for i in range(1000*1000):
        m.append("There's a fat fox jump over a sheep" + str(i))

    th_num = threading.active_count()
    print("Thread number is {}".format(th_num))
    return m

@asyncio.coroutine
def main():
    global loop
    global counter
    async_executor = concurrent.futures.ThreadPoolExecutor(max_workers=20)
    loop.run_in_executor(async_executor, prepare_a_giant_list)
    time.sleep(15)
    loop.run_in_executor(async_executor, prepare_a_giant_list)
    time.sleep(15)
    loop.run_in_executor(async_executor, prepare_a_giant_list)
    time.sleep(15)
    loop.run_in_executor(async_executor, prepare_a_giant_list)
    time.sleep(15)

if __name__ == "__main__":
    loop.run_until_complete(main())
    loop.close()
History
Date User Action Args
2019-08-21 20:55:03Tianshu Gaosetrecipients: + Tianshu Gao, asvetlov, yselivanov
2019-08-21 20:55:03Tianshu Gaosetmessageid: <1566420903.63.0.857548145971.issue37909@roundup.psfhosted.org>
2019-08-21 20:55:03Tianshu Gaolinkissue37909 messages
2019-08-21 20:55:03Tianshu Gaocreate