3 ms·
Each Linux thread has at least an 8MB virtual memory overhead. I just tested it, and was able to create one million coroutines in a few seconds and with a few h
by heavyset_go 6y ago
Each Linux thread has at least an 8MB virtual memory overhead. I just tested it, and was able to create one million coroutines in a few seconds and with a few hundred megabytes of overhead in Python. If I created just one thousand threads, it would take possibly 8 gigs of memory.
- shk1338 6y agoBut have you tried creating one thousand of OS threads and measuring the actual memory usage? If I recall correctly I read some article where it was explained that threads in Linux are not actually claiming their 8MB each so literally. I need to recheck that later.
- heavyset_go 6y agoYou're right, I've read the same. Using Python 3.8, creating 12,000 threads with `time.sleep` as the target clocks in at 200MB residential memory.
- otabdeveloper4 6y agoVirtual memory is not memory. You're effectively just bumping an offset, there's no actual allocations involved. > ...it would take possibly 8 gigs of memory. No. Nothing is 'taken' when virtual memory is requested.