Shahar,
 
Thank you very much.
I am going to use your advise ( actually I am advising on this to other team but I will ping them until they change static mapping to dynamic in their build system)
 
I will update the list on the results but your are absolutely correct that memory manager will do it.
Every kernel text book (as I remember now) says the same.
 
As you said text segment will be clean and memory manager will reuse pages sometime, I just not sure when it will happen, is it just last recently used page or other method, not such important.
 
Still I have one concern with a data section of this library. I think  data pages can be dirty, perhaps C++ make even use more  data page dirty versus C.
 
Can you elaborate why I can not write new system call to unmap this memory regions,  which I see in /proc/self/maps  by force ?
 
Thank you again.
I am relying on your and other Linux souls expertise who helped me on this issue.
 
Lev
 
 
 
21.12.2018, 20:18, "Shachar Shemesh" <shac...@shemesh.biz>:
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

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

Reply via email to