
From: David Collier-Brown via talk <talk@gtalug.org>
Niggle: the code (.txt) of the python interpreters is shared, but not the stack, the rss nor the heap.
Right. Except you don't mean rss, you mean data and bss segments (at least in the old days). ELF support a confusing array of segments, each with different characteristics.
Starting a new process still requires reading the binary from disk to get the rss contents and initial heap size. Slow!
TL;DR: I dig a little deeper but still have no explanation. Actually, ELF is designed to not require all of the binary. I would hope not: it can include extensive tables for debuggers). I think that loaders these days use memory mapped I/O. ELF has been designed to facilitate that. Only things that are touched get loaded. Read-only segments are shared. $ size /bin/python3 text data bss dec hex filename 1789 668 4 2461 99d /bin/python3 So: this is very small. it must just load the real python3 from somewhere else. $ ldd /bin/python3 linux-vdso.so.1 (0x00007fb51bf6e000) libpython3.13.so.1.0 => /lib64/libpython3.13.so.1.0 (0x00007fb51b800000) libc.so.6 => /lib64/libc.so.6 (0x00007fb51b60d000) libm.so.6 => /lib64/libm.so.6 (0x00007fb51be69000) /lib64/ld-linux-x86-64.so.2 (0x00007fb51bf70000) $ size /lib64/libpython3.13.so.1.0 text data bss dec hex filename 4611602 860128 496489 5968219 5b115b /lib64/libpython3.13.so.1.0 So there will be one copy of the text in the system memory even if there are hundreds of pythons. Some of the data segment will have one copy, some will be one-per-process. (There will be a bunch of data segments; the read-only ones will be shared.) The bss segment is uninitialized static variable. UNIX/Linux dictates that they will be zeroed before the probram starts. They occupy no disk space. The heap and stack don't show up until runtime. The biggest component is the immutable code: 4.5MB. that cannot explain memory use in the gigabyte range. Especially since there will be only one copy. The python code for (old) Mailman is mostly in /usr/lib/mailman/Mailman. The size of it, including .py and .pyc files, is only 3MB. That doesn't seem to be the culprit. But we really want to study Mailman2, and I don't have it.