On 21/12/2018 16:20, Lev Olshvang wrote:
Hi All,

I have  an executable (C++) which is the exclusive user of the some shared library that it uses only during  the initialization phase.

I would like to free memory used by this shared library, because I am running on embedded system.

How can I achieve this?

I know that dlopen() will load shared library, and hope that following dlclose() will free this lib memory. 

1. Still  I do not know what method should be used to make dynamic linker look again into executable and resolve symbols of the newly appeared symbols ?
2. And  how to tell the dynamic linker ld-linux.so to postpone the symbol resolution until dlopen()  will load  the library?
3. Whether to compile and link executable with this library or leave unresolved symbols?

What you are asking for, as asked, is not possible. If you explain your use case better, we might better understand what you're trying to do.


With that said, I think you should just link the library.


All the text segments of the library (i.e. - code) will be loaded with a read only shared mapping. This means that if they are not used, they will be unmapped the first time memory becomes constrained. If you do not use them later on, they will simply not be loaded to memory. They will still be mapped, but will not load your embedded system's memory in any significant way.


Shachar


_______________________________________________
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il

Reply via email to