Re: Debian shared libs use far more memory than required
Thiemo Seufer wrote:
Andreas Barth wrote:
DEBIAN PACKAGE FROM REPOSITORY:
11 .rodata 000840cb 000000000021a180 000000000021a180 ...
21 .data 000233c0 00000000003f1d60 00000000003f1d60 ...
MY OWN RECOMPILED DEBIAN PACKAGE:
11 .rodata 000a43ad 00000000001f3180 00000000001f3180 ...
21 .data 00000748 00000000003f3460 00000000003f3460 ...
That's 0x0233c0-0x748 = 140KB moved from shared to non-shared
140KB of non shared memory per GTK application is HUGE!!!
Fortunately it is not as bad as it sounds iff the constant data is
collated together in larger chunks. The kernel does copy-on-write,
if a .data page is never written, the memory usage is effectively
I checked the content of the .data section in libgtk and the
unexpected data appears to be composed of all exported
symbols aligned to a multiple of 16. Obviously a symbol
table of some kind.
Unfortunately, they only seem to be grouped per object file.
Some small non-constant data can be found every few KB.
I made a quick estimation and it seems that writing to those
non-constant data would access about 15 pages or 60K with
a 4K page size. Not as bad as the initial 140KB but still impressive.