<div xmlns="http://www.w3.org/1999/xhtml">Shahar,</div><div xmlns="http://www.w3.org/1999/xhtml"> </div><div xmlns="http://www.w3.org/1999/xhtml">Thank you very much.</div><div xmlns="http://www.w3.org/1999/xhtml">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)</div><div xmlns="http://www.w3.org/1999/xhtml"> </div><div xmlns="http://www.w3.org/1999/xhtml">I will update the list on the results but your are absolutely correct that memory manager will do it.</div><div xmlns="http://www.w3.org/1999/xhtml">Every kernel text book (as I remember now) says the same.</div><div xmlns="http://www.w3.org/1999/xhtml"> </div><div xmlns="http://www.w3.org/1999/xhtml">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.</div><div xmlns="http://www.w3.org/1999/xhtml"> </div><div xmlns="http://www.w3.org/1999/xhtml">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.</div><div xmlns="http://www.w3.org/1999/xhtml"> </div><div xmlns="http://www.w3.org/1999/xhtml">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 ?</div><div xmlns="http://www.w3.org/1999/xhtml"> </div><div xmlns="http://www.w3.org/1999/xhtml">Thank you again.</div><div xmlns="http://www.w3.org/1999/xhtml">I am relying on your and other Linux souls expertise who helped me on this issue.</div><div xmlns="http://www.w3.org/1999/xhtml"> </div><div xmlns="http://www.w3.org/1999/xhtml">Lev</div><div xmlns="http://www.w3.org/1999/xhtml"> </div><div xmlns="http://www.w3.org/1999/xhtml"> </div><div xmlns="http://www.w3.org/1999/xhtml"> </div><div xmlns="http://www.w3.org/1999/xhtml">21.12.2018, 20:18, "Shachar Shemesh" <shachar@shemesh.biz>:</div><blockquote type="cite">
<div bidimailui-charset-is-forced="true" style="direction:ltr;" text="#000000" bgcolor="#FFFFFF">
<div>On 21/12/2018 16:20, Lev Olshvang
wrote:<br />
</div>
<blockquote type="cite" cite="mid:965981545402036@sas1-2b3c3045b736.qloud-c.yandex.net">
<pre wrap="">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?</pre>
</blockquote>
<p>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.</p>
<p><br />
</p>
<p>With that said, I think you should just link the library.</p>
<p><br />
</p>
<p>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.</p>
<p><br />
</p>
<p>Shachar<br />
</p>
<br />
</div>
,<p>_______________________________________________<br />Linux-il mailing list<br /><a href="mailto:Linux-il@cs.huji.ac.il">Linux-il@cs.huji.ac.il</a><br /><a href="http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il">http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il</a><br /></p></blockquote>