Re: Memory statistics

Federico Mena Quintero a écrit :

>I started writing a small script that should eventually let us answer
>questions like these:
>- How much memory are we using in the writable mappings for libraries?
>Is it worthwhile to hunt down non-const arrays and such?
Alas, non-const arrays are not the only problem. With
position-independent code, any constant
_pointer_ will be stored in writable pages, to be relocated by the
dynamic loader before being usable.
This has a huge impact on C++ libraries, since all their VTables contain
constant pointers (try running
your script on a KDE system !). Many C libraries also use plenty of
small constant structures
containing pointers.

It'd be nice if the dynamic linker was able to automatically share the
updated pointers between
processes which map the same libraries to the same virtual addresses,
but I don't think this has been
implemented yet, since it would require a new ELF section, as well as
modifications to the

Another option is to get rid of PIC code completely, using an alternate
dynamic linking scheme,
similar to the one in Windows, without the crap. If rebasing is used,
relocation can be reduced to
nearly nothing for the most common libraries. This would also create
smaller and faster code.

Not that this is an easy solution either, and there are downsides to it,
one of them being that the
toolchain changes would be even more problematic.

Oh well, just my 2 cents :-)


- David Turner
- The FreeType Project  (

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]