<div class="gmail_quote">Hello Michal,<br><br>2012/3/5 Michal Trojnara <span dir="ltr"><<a href="mailto:Michal.Trojnara@mirt.net" target="_blank">Michal.Trojnara@mirt.net</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I am using fork mode because of leaks with pthread. In 4.33+pthread,<br>
stunnel virt size (per top) went up to 216m after 40k transactions. In<br>
fork mode, stunnel size after the same test was 20744 (kilobytes). In<br>
4.45, I have 187m and 20676k respectively.<br>
</blockquote>
</div><br>
I observed the same symptoms. Stunnel grows to ~200MB of virtual memory after some time of usage. �Then it stops growing further. �I guess this issue is caused by heap fragmentation rather than a memory leak. �Otherwise the growth would not be limited to ~200MB.<br>
<a href="https://en.wikipedia.org/wiki/C_dynamic_memory_allocation" target="_blank">https://en.wikipedia.org/wiki/<u></u>C_dynamic_memory_allocation</a></blockquote><div><br><br>I ran a test overnight that confirmed your point. I generated 480k+ stunnel transactions. This morning, stunnel memory usage is virt=187m and res=42m. My result after 40k transactions was exactly the same (in both cases with pthread+zlib).<br>
<br><br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I understand that virt includes shared libs, and that any issue with a<br>
shared lib will impact virt size. I did not have the opportunity to test<br>
without zlib support in openssl. Since we are not using compression, I<br>
wonder how much avoiding zlib would help.<br>
</blockquote>
<br></div>
zlib only uses lots of memory when it's enabled.<br></blockquote><div><br><br>I ran another test to clarify this. zlib appears to be adding around 3 megabytes at most. This is at least what I see under my setup and type of usage.<br>
<br>pthread+zlib, 40k transactions<br>before: virt=20680, res=792<br>after: virt=187m, res=42m<br><br>pthread+nozlib, 40k transactions<br>before: virt=20688, res=896<br>after: virt=185m, res=39m<br><br>I have seen no benefit of compiling without zlib in fork mode. I guess it only makes forking a bit lighter.<br>
<br></div></div><br>2012/3/5 Michal Trojnara <span dir="ltr"><<a href="mailto:Michal.Trojnara@mirt.net" target="_blank">Michal.Trojnara@mirt.net</a>></span><br><div>�</div><blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
You may also try to set a lower value of MMAP_THRESHOLD to reduce heap fragmentation:<br><a href="https://www.kernel.org/doc/man-pages/online/pages/man3/malloc.3.html" target="_blank">https://www.kernel.org/doc/man-pages/online/pages/man3/malloc.3.html</a><br>
</blockquote><br><br>This will be worth a look. Knowing what is influencing stunnel size is nice since it can avoid us restarting the processes once in a while (which we currently never do in fork mode).<br><br>Thanks for your great help!<br>