<div dir="ltr"><div>Hi</div><div><br></div><div>I use mapserver which is using gdal for raster from local files. mapserv is running as processes under fcgi module from apache2<br>My use case is raster netcdf data in a custom reprojection stored locally with a week of data every 5 minutes, with new data every 5 minute.<br>Mapserver, using the raster gdal, reads the data, resample and return the data. This works fine.<br><br>If I test with requesting the same dataset again and again for hundreds of times, I see little or no memory usage increase of the mapserv process.<br><br>However, my setup is datasets with many timestamps. One timestamp per netcdf file.<br>If I request each dataset once for each timestamp, I see a steady increase in memory usage of the mapserv process ( still running under fcgi module and apache2). I'm guessing this as gdal is caching data. So where does all this memory usage come from?<br><br>I have run valgrind on the mapserv process as a standalone processi. No leaks.<br>I have run valgrind on apache2 running the fcgi module running the mapserv as a long living process. No leaks as far as I can see.<br><br>I suspect the gdal block cache mechanism. There is an environmental variable GDAL_CACHEMAX, which should control the GDAL CACHE usage?<br><br>However I have tried to set GDAL_CACHEMAX to various values, even to 0 ( and verified the variable is read with logs output like: <br><br></div><div>[Thu Feb 26 07:05:34.677597 2026] [fcgid:warn] [pid 421231:tid 421234] [client ::1:60610] mod_fcgid: stderr: msDrawRasterLayerGDAL(): <br>[Thu Feb 26 07:05:34 2026].6776, 0.0302: GDAL: GDALDefaultOverviews::OverviewScan()<br>[Thu Feb 26 07:05:34 2026].6777, 0.0303: LOCK: Lock contention : max = 510, avg = 510<br>[Thu Feb 26 07:05:34 2026].6778, 0.0303: GDAL: GDAL_CACHEMAX = 0 MB<br>[Thu Feb 26 07:05:34 2026].6778, 0.0303: LOCK: Lock contention : max = 6882, avg = 3696<br></div><div><br></div><div>But still, the memory usage just increases, in what I see, in an uncontrolled manner.</div><div><br></div><div>This leads to eventually OOM kills of the mapserv process.</div><div><br></div><div>I can of course set the fcgi environmental variable FcgidMaxRequestsPerProcess to a low value, but that will require the fcgi module to respawn new mapserv processes all the time.</div><div><br></div><div>The data is stored locally, so no vsi is involved as far as I can see.</div><div><br></div><div>It must be a way to control the memory usage in gdal in a better way ( if this really is gdal causing this)</div><div><br></div><div>Any ideas?<br><br>This test has been set up using mapserver 8.6, gdal 3.12.2 on a ubuntu noble system.</div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div dir="ltr">Trygve Aspenes - Senioringeniør/Senior Engineer
<br>Telefon/Phone: +47 48223736</div><div dir="ltr">Observasjonskvalitet og databehandling (OKD) <br>Observasjonsdivisjonen/Department of observation<br>Meteorologisk Institutt /MET Norway</div>Postboks 43, Blindern 0313 OSLO, NORWAY<br></div></div></div>