<html style="direction: ltr;">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
</head>
<body bidimailui-charset-is-forced="true" style="direction: ltr;"
text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 23/12/2018 09:49, Lev Olshvang
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:3942691545551395@iva1-5148b5385b62.qloud-c.yandex.net">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div xmlns="http://www.w3.org/1999/xhtml">Boker tov,</div>
<div xmlns="http://www.w3.org/1999/xhtml"> </div>
<div xmlns="http://www.w3.org/1999/xhtml">Thanks for all of your
replies that helped me to understand what question I really
wanted to ask.</div>
<div xmlns="http://www.w3.org/1999/xhtml"> </div>
<div xmlns="http://www.w3.org/1999/xhtml">So this is a question.</div>
<div xmlns="http://www.w3.org/1999/xhtml"> </div>
<div xmlns="http://www.w3.org/1999/xhtml">I have C++ program
which calls many services of third party library.</div>
<div xmlns="http://www.w3.org/1999/xhtml">This library is needed
only on initialization phase of my program.</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">Linker has resolved
symbols of this library and now it is bound to executable and in
a run tine</div>
<div xmlns="http://www.w3.org/1999/xhtml">this lib will be mapped
will have <b>use count > 0</b> while executable is in
use.</div>
<div xmlns="http://www.w3.org/1999/xhtml">I would like to unmap it
to release memory, but i do not know how to do it in user space.</div>
<div xmlns="http://www.w3.org/1999/xhtml"> </div>
<div xmlns="http://www.w3.org/1999/xhtml">As an alternative I know
that by using dynamic loader calls dlopen() .. dlclose() I can
achieve the desired effect</div>
<div xmlns="http://www.w3.org/1999/xhtml"> </div>
<div xmlns="http://www.w3.org/1999/xhtml">The problem that I need
to add a lot of dlfind() calls, and I looked for a way dynamic
loader can do it.</div>
<div xmlns="http://www.w3.org/1999/xhtml">I am not that lazy, but
since the code is C++, function names are mangled and I was
tring to avoid this</div>
<div xmlns="http://www.w3.org/1999/xhtml">by looking as a subject
of this mail said, way to ask kernel to unmap this lib</div>
<div xmlns="http://www.w3.org/1999/xhtml"> </div>
<div xmlns="http://www.w3.org/1999/xhtml">I wish we have __init
attribute in a user land !</div>
<div xmlns="http://www.w3.org/1999/xhtml"> </div>
</blockquote>
<p>First, yes, it will have a use count of more than zero. So what?
All the pages are clean, and have a file that has a copy. The
kernel will gladly remove them from memory despite being mapped
(unless you mlock them, that is). If, as you say, they are not
used after init, then nothing will fault them and cause them to
come back.</p>
<p><br>
</p>
<p>
<blockquote type="cite">I am not that lazy,</blockquote>
It's not about being lazy. It's about opening yourself up for
introducing bugs. I wouldn't do that.<br>
</p>
<p><br>
</p>
<p>Assuming you're still not convinced, here's what I <i>would</i>
do: Write your own library (liblevinit.so). Put all the calls that
need to go into that other library into liblevinit.so. dlopen and
dlsym lev init, call the trigger function, and then dlclose it.
You now have to manage only one symbol, and <br>
</p>
<p><br>
</p>
<p>Like I said above, I don't think that is necessary. If you want
to be paranoid about it, however, that's what I'd do.</p>
<p><br>
</p>
<p>Shachar<br>
</p>
</body>
</html>