TransWikia.com

Does Pulseaudio leak memory?

Unix & Linux Asked on October 31, 2021

I invoked the top command and got this:

 PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                  
3433 klutt     20   0 4790760   1.0g 282208 S   8.3   4.2   1261:15 firefox-esr              
2063 klutt      9 -11 3424532  33644  24432 S   7.0   0.1 432:44.69 pulseaudio               
3681 klutt     20   0 3958364 545000 139800 S   6.6   2.2 434:35.72 Web Content       

I understand that firefox and Web content are using a lot of memory, but pulseaudio? Is it normal that it is using over 3GB? Is it a bug?

$ uname -a
Linux desktop 5.7.0-1-amd64 #1 SMP Debian 5.7.6-1 (2020-06-24) x86_64 GNU/Linux

$ pulseaudio --version
pulseaudio 13.0

$ cat /etc/debian_version 
bullseye/sid

2 Answers

You can see more details on the virtual memory usage using the pmap tool:

pmap $(pidof pulseaudio) | sort -hk 2

00005590f6f0a000      4K r---- pulseaudio
00005590f6f0b000      4K rw--- pulseaudio
00007f50ea53f000      4K r---- libicudata.so.66.1
00007f50ea540000      4K r-x-- libicudata.so.66.1
....
00007f50e0000000  65536K rw-s- memfd:pulseaudio (deleted)
00007f50f314b000  65536K rw-s- memfd:pulseaudio (deleted)
 total          1679768K

For me, most of the memory used is 64MB memfd buffers. memfd is a method of communicating between processes, and it is used by applications to transfer audio data to pulseaudio.

Even though the virtual memory for the buffers is allocated for each application, actual memory is only used to the amount of data currently in transit. When application writes audio samples to the buffer, memory is allocated for it. Once pulsaudio has mixed and played the samples, the memory is again released.

Answered by jpa on October 31, 2021

In your example, pulseaudio is using 32MB not 3GB. The RES column is physical memory. The VIRT column shows all the virtual memory used by the process. According to man top, that includes all code, data, and shared libraries plus pages that have been swapped out and pages that have been mapped but not used.

Answered by Andy Dalton on October 31, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP