Hi all,
We run a multi-tenant PBX and see Asterisk’s memory (RSS) grow by about 240 MB on every dialplan reload. It is never released, so we have to restart Asterisk once or twice a day.
Setup
- Asterisk [22.8.2], Ubuntu, 15 GB RAM, no swap.
- About 90 tenants and about 7,300 PJSIP endpoints, with endpoints, AORs, auths and contacts loaded from MariaDB through ODBC realtime (no sorcery memory cache yet).
- The dialplan comes from generated
.conffiles loaded with#tryinclude: one file per tenant plus a few shared files. Size:-= 74641 extensions (546727 priorities) in 23116 contexts. =- . - About 1,150 hints. We cut them from about 74,000, and that brought reload time from about 60 s down to about 1.5 s.
- A web panel runs
dialplan reloadafter edits (extensions, IVRs, DIDs, and so on). Reloads are coalesced, one at a time, and skipped when no file changed. We still get about 30–40 reloads on a busy weekday.
What we measured (RSS of the Asterisk process, 5 seconds after each reload, with about 5 calls active):
before 8456 MB
reload 1 8706 MB (+250)
reload 2 8934 MB (+228)
10 min, no reload: 8934 -> 8934 MB (flat)
Earlier the same day it was 8134 → 8380 MB (+246) for a single reload. Memory doesn’t level off after a few reloads. It only grows when a reload happens. Calls, registrations and CDR/CEL don’t make it grow.
Things we checked
core show taskprocessors: no queue backlog (all “In Queue” are 0).- ODBC connections are normal (1 of 1 per DSN). CDR/CEL go to ODBC.
- Hints are stable at 1,154.
Questions
- Is it expected that a
dialplan reloadwith calls active keeps the old dialplan’s memory, so RSS grows by roughly the size of the dialplan each time? - Has anyone had
MALLOC_ARENA_MAX=2(or callingmalloc_trim) fix this, or does it point to a real leak inpbx_configor the hint/context handling? - Is there a better way to apply dialplan changes for one tenant without reloading the whole dialplan? For example, something we could do through
pbx_lua/pbx_realtime, AstDB-driven contexts, or reloading only part of the configuration. - If a MALLOC_DEBUG build would help, which
memory showoutput would you like to see?
We can test patches or debug builds on a staging copy. Thanks!