<div dir="ltr"><div>Hi all,</div><div><br></div><div>We (@<a href="http://3liz.com">3liz.com</a>) use QGIS Server since a long time to provide hosting services for our clients, with Lizmap Web Client (LWC) as the web map builder.</div><div><br></div><div>Having hundred LWC instances, we pay obviously attention to metrics, and monitor the CPU, memory, requests response time, etc.</div><div><br></div><div>We sometimes encounter heavy memory consumption for specific projects, for example :</div><div><a href="https://github.com/qgis/QGIS/issues/43787">https://github.com/qgis/QGIS/issues/43787</a></div><div>which put a lot of strain to the servers.<br></div><div><br></div><div>It is often very hard to find the project(s) responsible for a high memory usage, in a production context, when many requests are run in parallel for many projects.<br></div><div><br></div><div>I created a POC processing script to audit all the QGIS projects stored in a folder:</div><div><a href="https://gist.github.com/mdouchin/cd89a259d3560635d4bb8708ad430caa/">https://gist.github.com/mdouchin/cd89a259d3560635d4bb8708ad430caa/</a></div><div>which helps a bit to gather some key figures, such as the number of layers, the sum of the images used in map layouts, etc.<br></div><div>This can help, but often the memory consumption is not related to the number of layers, and we use a "find a needle in the haystack" approach to find the problematic project(s).</div><div><br></div><div>For example, I spent once a whole day finding that a too big JPEG used in a print layout causes the heavy memory usage: <br></div><div>* look at the memory curve, <br></div><div>* find the moment when the memory increased a lot</div><div>* use the command line find  to get which QGIS project files has changed during this period (for example because it has been uploaded by the user)<br></div><div>* look inside QGIS logs to find which project has been loaded during this period, and compare</div><div>* if you are lucky, there are not so many projects involved...<br></div><div>* download the project, open it in QGIS Desktop to observe and confirm the memory issue</div><div>* try to understand which causes the issue</div><div>* ...<br></div><div><br></div><div>We are also building a REST API over py-qgis-server ( <a href="https://github.com/3liz/py-qgis-server">https://github.com/3liz/py-qgis-server</a> ) which will allow to get information on the loaded projects, to ease the auditing process in real-time. (It will be opensource). <br></div><div><br></div><div>In the processing script, and in this API tool, we still miss a very important metric: how much each project consumes the system memory (RAM). I am not sure it could be easily done, but it will be very handy to:</div><div><br></div><div>* find heavy memory consumer projects</div><div>* see how the memory evolves</div><div>* compare the memory usage for each QGIS versions (with the same project and layers)</div><div>* help to find the possible memory leaks<br></div><div><br></div><div>This message is not a feature request, I would like to get your experience and opinion regarding this memory usage issue. Any contribution welcome ;-)<br></div><div><br></div><div>Thanks in advance</div><div>Michaël<br></div></div>