All of lore.kernel.org
 help / color / mirror / Atom feed
From: mru@users.sourceforge.net (Måns Rullgård)
To: Jaroslav Kysela <perex@suse.cz>
Cc: "alsa-devel@lists.sourceforge.net" <alsa-devel@lists.sourceforge.net>
Subject: Re: Memory leaks in alsa-lib
Date: Tue, 26 Aug 2003 13:53:43 +0200	[thread overview]
Message-ID: <yw1xptis1vp4.fsf@users.sourceforge.net> (raw)
In-Reply-To: <Pine.LNX.4.44.0308261159450.29234-100000@pnote.perex-int.cz> (Jaroslav Kysela's message of "Tue, 26 Aug 2003 12:07:36 +0200 (CEST)")

Jaroslav Kysela <perex@suse.cz> writes:

>> Is there a memory leak in alsa-lib?  When playing music with a player
>> I'm writing (TCVP, http://tcvp.sf.net), the memory usage reported by
>> top grows for each file I play, but only if I use ALSA for sound
>> playback.  If I use OSS the memory usage varies around 1.5 MB, but if
>> I use ALSA, it starts at 1.9 MB (OK, libasound takes some space) and
>> grows by 30-40 kB for each played file.  Running the whole thing under
>> valgrind gives me this, which is all alsa-related.  When using OSS,
>> valgrind reports no leaks.
>
> I tested aplay with valgrind and I cannot find any leak (except a few 
> allocations probably from glibc). Note that you have to use 
> snd_config_update_free_global() after end of the session to free

OK, so what constitutes a session?  A snd_pcm_open/snd_pcm_close pair?
Won't snd_pcm_open reuse the data from a previous call?

I added that call after my call to snd_pcm_open, and valgrind no
longer reports any leaks, except for a few kilobytes from a flex
scanner (not related to alsa).  Still, the memory used by the player
when running increases with each file.  The virtual size of the player
is rather constant at around 25 MB all the time, while the resident
size is slowly increasing, until it too reaches 25 MB.  Then the
impossible happens:

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           
 7148 mru       11   0 25160  27m 2740 S  0.0 12.4   0:00.08 tcvp              

Now the man page for top tells me that "VIRT = SWAP + RES", so unless
a negative amount has been swapped (what would that mean?), something
strange is going on.  The odd thing is that this happens only when I
use the ALSA output module.  Could it be that alsa-lib triggers some
bug somewhere in top, or in the kernel?  This seems a little unlikely,
though.

In case it matters, I use ALSA OSS emulation when testing OSS sound.

> the configuration cache in alsa-lib. This is described in 
> the alsa-lib/MEMORY-LEAK file.

That file isn't present in the alsa-lib 0.9.6 tarball.  It should be
added the EXTRA_DIST list in Makefile.am.

I ran valgrind on aplay, and it tells me more or less the same as for
my program.  Does aplay not call the above function?  Not that it
needs to, really.


-- 
Måns Rullgård
mru@users.sf.net


-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines
at the same time. Free trial click here:http://www.vmware.com/wl/offer/358/0

  reply	other threads:[~2003-08-26 11:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-25 16:07 Memory leaks in alsa-lib Måns Rullgård
2003-08-26 10:07 ` Jaroslav Kysela
2003-08-26 11:53   ` Måns Rullgård [this message]
2003-08-26 12:33     ` Jaroslav Kysela
2003-08-26 13:14       ` Måns Rullgård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yw1xptis1vp4.fsf@users.sourceforge.net \
    --to=mru@users.sourceforge.net \
    --cc=alsa-devel@lists.sourceforge.net \
    --cc=perex@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.