<p></p>
<p>I think in this issue two different issues are mixed, both around memory not freed. The initial report was about the RSS of renderd growing.</p>
<p>I have with my recent setup (using tirex) a similar problem like described by <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/users/duerk-de/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/duerk-de">@duerk-de</a>. In that case the RssAnon of the postgres backends is growing. A single backend grow with a rendering queue fully busy during this time leads to a growth of roughly 3GB within 7 hours for each rendering instance:</p>
<p>RssAnon:  from 352.532 to 3.343.852, increase by 2.991.320</p>
<p>resetting the database connection frees this memory. I also have the suspicion that this is related to mapnik using persistent connections to postgis. By looking at the source code I think this is used in the same way in renderd and tirex.</p>
<p>A workaround with tirex is to send SIGHUP to the rendering backend manager. I would feel better if the root cause is understood.</p>
<p>Postgresql developer documentation suggests dumping the allocation structure with gdb, but I fear I won't understand the output without deeply digging into Postgresql.</p>
<blockquote>
<p>Examining backend memory use<br>
PostgreSQL's palloc is a hierarchical memory allocator that wraps the platform allocator. See #Why do we use palloc() and pfree() to allocate memory?.</p>
<p>Memory allocated with palloc is assigned to a memory context that's part of a hierarchy rooted at TopMemoryContext. Each context has a name.</p>
<p>You can dump stats about a memory context and its children using the MemoryContextStats(MemoryContext*) function. In the most common usage, that's:</p>
<p>gdb -p $the_backend_pid<br>
(gdb) p MemoryContextStats(TopMemoryContext)<br>
The output is written to stderr.</p>
<p>This may appear in the main server log file, a secondary log used by the init system for before PostgreSQL's logging collector starts, journald, or on your screen if you are running a backend directly without a postmaster.</p>
</blockquote>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you commented.<br />Reply to this email directly, <a href="https://github.com/openstreetmap/mod_tile/issues/181#issuecomment-808962223">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AA6353QRVDLP3UUUXLLYMYTTF6UT7ANCNFSM4FDRE4HQ">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AA6353UIIKLAOHW7ZGULSZ3TF6UT7A5CNFSM4FDRE4H2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOGA34RLY.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/mod_tile/issues/181#issuecomment-808962223",
"url": "https://github.com/openstreetmap/mod_tile/issues/181#issuecomment-808962223",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>