Summary
On Asterisk 22.10.1, pjsip/outsess taskprocessors continue to accumulate after outbound PJSIP calls have completed. The taskprocessors remain registered even when there are no active outbound calls.
While investigating a memory issue, we initially suspected these taskprocessors were responsible. However, further testing showed they are not the cause of the high RSS memory usage. After forcing malloc_trim(0), the process RSS dropped from approximately 30 GB to 5.3 GB, while the number of pjsip/outsess taskprocessors remained unchanged.
This suggests the taskprocessors are persistent idle objects rather than the source of memory consumption.
Environment
- Asterisk Version: 22.10.1
- Channel Driver: PJSIP
- Operating System: Linux
- Call Type: High-volume outbound dialing using Dialplan + AGI
- Call Flow:
Inbound Trigger
↓
Dialplan
↓
AGI(tff/broadcast.agi)
↓
Dial(PJSIP/...)
↓
Outbound Call
No AMI or ARI is used for originating calls.
Problem Description
After processing approximately 186,000 outbound calls, the system reports:
1 active channel
1 active call
186797 calls processed
However:
asterisk -rx "core show taskprocessors" | grep '^pjsip/outsess' | wc -l
63467
The number of taskprocessors remains around 63,000 even when only a single active call exists.
Sample Output
pjsip/outsess/0091160030808d-0004ea64
pjsip/outsess/009116003080866d-000536ea
pjsip/outsess/009116003080866d-00055866
Representative entries:
pjsip/outsess/009116003080514cc
4 0 1 450 500 0 388960
pjsip/outsess/0091796979704d5d6
7 0 1 450 500 0 42543
Observations:
- Queue Depth = 0
- Max Depth = 1
- Taskprocessors appear completely idle.
- They do not disappear after calls terminate.
Memory Investigation
Before calling malloc_trim(0):
VmRSS: ~30 GB
After executing:
call (int) malloc_trim(0)
RSS immediately reduced to:
VmRSS: ~5.3 GB
The pjsip/outsess count remained unchanged:
63467
Therefore:
- High RSS was due to allocator retention and not these taskprocessors.
- However, the taskprocessors themselves remain registered indefinitely.
Expected Behavior
When an outbound PJSIP session is destroyed, its associated pjsip/outsess taskprocessor should also be released unless intentionally cached by design.
After completed calls, the number of idle pjsip/outsess taskprocessors should not continue to grow indefinitely.
Actual Behavior
Completed outbound sessions leave behind idle pjsip/outsess taskprocessors.
The total number increases over time with call volume and does not decrease, even when there are virtually no active calls.
Questions
- Is this expected behavior for
pjsip/outsesstaskprocessors? - Are these taskprocessors intentionally retained for reuse?
- If not, could there be a missing cleanup path for outbound session serializers in Asterisk 22.10.1?
- Has this behavior already been fixed in a later 22.x release?
Any guidance on whether this is expected or a regression would be appreciated.