Skip to main content
Put all instances of `a` and `b` in backtick for better reading
Source Link

I'm wondering about the way Linux manages shared libraries. (actually I'm talking about Maemo Fremantle, a Debian-based distro released in 2009 running on 256MB RAM).

Let's assume we have two executables linking to libQtCore.so.4 and using its symbols (using its classes and functions). For simplicity's sake let's call them aa and bb. We assume that both executables link to the same libraries.

First we launch a. The library has to be loaded. Is it loaded in whole or is it loaded to the memory only in the part that is required (as we don't use each class, only the code regarding the used classes is being loaded)?

Then we launch b. We assume that aa is still running. bb links to libQtCore.so.4 too and uses some of the classes that aa uses, but also some that aren't used by a. Will the library be double loaded (separately for aa and separately for bb)? Or will they use the same object already in RAM. If bb uses no new symbols and aa is already running will the RAM used by shared libraries increase? (Or will the difference be insignificant)

I'm wondering about the way Linux manages shared libraries. (actually I'm talking about Maemo Fremantle, a Debian-based distro released in 2009 running on 256MB RAM).

Let's assume we have two executables linking to libQtCore.so.4 and using its symbols (using its classes and functions). For simplicity's sake let's call them a and b. We assume that both executables link to the same libraries.

First we launch a. The library has to be loaded. Is it loaded in whole or is it loaded to the memory only in the part that is required (as we don't use each class, only the code regarding the used classes is being loaded)?

Then we launch b. We assume that a is still running. b links to libQtCore.so.4 too and uses some of the classes that a uses, but also some that aren't used by a. Will the library be double loaded (separately for a and separately for b)? Or will they use the same object already in RAM. If b uses no new symbols and a is already running will the RAM used by shared libraries increase? (Or will the difference be insignificant)

I'm wondering about the way Linux manages shared libraries. (actually I'm talking about Maemo Fremantle, a Debian-based distro released in 2009 running on 256MB RAM).

Let's assume we have two executables linking to libQtCore.so.4 and using its symbols (using its classes and functions). For simplicity's sake let's call them a and b. We assume that both executables link to the same libraries.

First we launch a. The library has to be loaded. Is it loaded in whole or is it loaded to the memory only in the part that is required (as we don't use each class, only the code regarding the used classes is being loaded)?

Then we launch b. We assume that a is still running. b links to libQtCore.so.4 too and uses some of the classes that a uses, but also some that aren't used by a. Will the library be double loaded (separately for a and separately for b)? Or will they use the same object already in RAM. If b uses no new symbols and a is already running will the RAM used by shared libraries increase? (Or will the difference be insignificant)

Source Link
marmistrz
  • 2.8k
  • 4
  • 25
  • 33

Loading of shared libraries and RAM usage

I'm wondering about the way Linux manages shared libraries. (actually I'm talking about Maemo Fremantle, a Debian-based distro released in 2009 running on 256MB RAM).

Let's assume we have two executables linking to libQtCore.so.4 and using its symbols (using its classes and functions). For simplicity's sake let's call them a and b. We assume that both executables link to the same libraries.

First we launch a. The library has to be loaded. Is it loaded in whole or is it loaded to the memory only in the part that is required (as we don't use each class, only the code regarding the used classes is being loaded)?

Then we launch b. We assume that a is still running. b links to libQtCore.so.4 too and uses some of the classes that a uses, but also some that aren't used by a. Will the library be double loaded (separately for a and separately for b)? Or will they use the same object already in RAM. If b uses no new symbols and a is already running will the RAM used by shared libraries increase? (Or will the difference be insignificant)