<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">I solved my problem... I found a way to reduce memory utilization and allocations when using MapServer with GDAL >= 2.3.0: </div><div dir="ltr"><br></div><div dir="ltr">     CONFIG "GDAL_HTTP_MULTIRANGE"       "SERIAL"<br></div><div dir="ltr"><br></div><div>With this setting, the memory footprint matches that of GDAL <= 2.2.4.</div><div dir="ltr"><br></div><div>With the default (YES) has mapserv allocates much more memory. Running mapserv with supervisor & configured over FCGI results in a much higher memory footprint over time. My best guess is that with the default parallel mode has many HTTP connections kept alive and each connection consumes some non-trivial amount of memory.  With CONFIG "CPL_CURL_VERBOSE" "ON", I see 9 HTTP connections kept around only with the default GDAL_HTTP_MULTIRANGE=ON setting:</div><div><br></div><div><div>* Curl_http_done: called premature == 0</div><div>* Connection #17 to host <a href="http://s3.amazonaws.com">s3.amazonaws.com</a> left intact</div><div>* Curl_http_done: called premature == 0</div><div>* Connection #11 to host <a href="http://s3.amazonaws.com">s3.amazonaws.com</a> left intact</div><div>* Curl_http_done: called premature == 0</div><div>* Connection #13 to host <a href="http://s3.amazonaws.com">s3.amazonaws.com</a> left intact</div><div>* Curl_http_done: called premature == 0</div><div>* Connection #14 to host <a href="http://s3.amazonaws.com">s3.amazonaws.com</a> left intact</div><div>* Curl_http_done: called premature == 0</div><div>* Connection #15 to host <a href="http://s3.amazonaws.com">s3.amazonaws.com</a> left intact</div><div>* Curl_http_done: called premature == 0</div><div>* Connection #19 to host <a href="http://s3.amazonaws.com">s3.amazonaws.com</a> left intact</div><div>* Curl_http_done: called premature == 0</div><div>* Connection #16 to host <a href="http://s3.amazonaws.com">s3.amazonaws.com</a> left intact</div><div>* Curl_http_done: called premature == 0</div><div>* Connection #18 to host <a href="http://s3.amazonaws.com">s3.amazonaws.com</a> left intact</div><div>* Curl_http_done: called premature == 0</div><div>* Connection #12 to host <a href="http://s3.amazonaws.com">s3.amazonaws.com</a> left intact</div></div><div><br></div><div>Side-note: the comments in cpl_vsil_curl.cpp for GDAL_HTTP_MULTIRANGE do not match the ConfigOptions documentation </div><div dir="ltr"><a href="https://github.com/OSGeo/gdal/blob/1d799cf5d8c399d9ac3feb7ef9f05dc6e3297a82/gdal/port/cpl_vsil_curl.cpp#L2691-L2696">https://github.com/OSGeo/gdal/blob/1d799cf5d8c399d9ac3feb7ef9f05dc6e3297a82/gdal/port/cpl_vsil_curl.cpp#L2691-L2696</a><br></div><div dir="ltr"><a href="https://trac.osgeo.org/gdal/wiki/ConfigOptions#GDAL_HTTP_MULTIRANGE">https://trac.osgeo.org/gdal/wiki/ConfigOptions#GDAL_HTTP_MULTIRANGE</a><br></div><div>The valid settings are actually SINGLE_GET, SERIAL or _anything_ else for "parallel" mode</div><div><br></div><div>It's great to see all the vsicurl improvements to GDAL which MapServer can leverage!  Time for me to experiment with the other gdal-2.3 config options for libcurl >= 7.33 built with <span style="color:rgb(0,0,0);font-family:Verdana,Arial,"Bitstream Vera Sans",Helvetica,sans-serif;font-size:13px">nghttp2.</span></div><div><br></div><div>Cheers,</div><div>Pete</div></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 29, 2019 at 3:02 PM Peter Schmitt <<a href="mailto:pschmitt@gmail.com">pschmitt@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi,</div><div><br></div><div>I run MapServer in a Docker container. I noticed its memory utilization climbed much higher than expected. This seems to happen only under the following conditions:</div><div><br></div><div>* Files are accessed network-based filesystems (I tried both /vsicurl/ and /vsis3/)</div><div>* Using gdal  > 2.2.4 (tested with 2.3.0, 2.3.2 & 2.4.1.  I see the same behavior with both MapServer-7.0.7 and MapServer-7.2.2.</div><div><br></div><div>I had a hard time isolating this to GDAL and could not reproduce with similar gdal_translate commands.  So I put together a little example to try and demonstrate the problem.</div><div><a href="https://github.com/pedros007/gdal_mapserver_memory" target="_blank">https://github.com/pedros007/gdal_mapserver_memory</a><br></div><div dir="ltr"><br></div>Does anyone have any ideas as to what might be going on? I tried various cache settings, which do not seem to reduce memory utilization:</div><div dir="ltr"><a href="https://github.com/pedros007/gdal_mapserver_memory/blob/master/mapfiles/indonesian_redcross.map#L15-L18" target="_blank">https://github.com/pedros007/gdal_mapserver_memory/blob/master/mapfiles/indonesian_redcross.map#L15-L18</a><br class="gmail-m_-7793784985816888100gmail-Apple-interchange-newline"><div dir="ltr"><div><br></div><div dir="ltr" class="gmail-m_-7793784985816888100gmail_signature">Thanks,</div><div dir="ltr" class="gmail-m_-7793784985816888100gmail_signature">Pete</div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Pete</div>