All of lore.kernel.org
 help / color / mirror / Atom feed
* Memleak with mixer? Or incorrect code?
@ 2005-01-12 11:23 Reimar Döffinger
  2005-01-13 17:07 ` Takashi Iwai
  0 siblings, 1 reply; 3+ messages in thread
From: Reimar Döffinger @ 2005-01-12 11:23 UTC (permalink / raw)
  To: alsa-devel

[-- Attachment #1: Type: text/plain, Size: 425 bytes --]

Hi,
the attached code consumes more and more memory when I run it (with alsa
1.0.3 as included in SuSE 9.1).
Why is that so? Did I forget to free something?
Both commenting out the snd_mixer_selem_register or the snd_mixer_load
call will fix it, but that's not an option in real code (this is
actually a stripped-down version of the code in MPlayer's ao_alsa.c)...
Any hints on that??

Greetings,
Reimar Döffinger

[-- Attachment #2: alsa.c --]
[-- Type: text/plain, Size: 439 bytes --]

#include <alsa/asoundlib.h>

int main() {
  snd_mixer_t *handle; 
  snd_mixer_selem_id_t *sid;
  snd_mixer_class_t *class;
  int err;
  while (1) {
    snd_mixer_open(&handle, 0);
    snd_mixer_attach(handle, "default");
    snd_mixer_selem_register(handle, NULL, NULL);
    snd_mixer_load(handle);
    snd_mixer_free(handle);
    snd_mixer_detach(handle, "default");
    snd_mixer_close(handle);
//    sleep(100);
  }
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Memleak with mixer? Or incorrect code?
  2005-01-12 11:23 Memleak with mixer? Or incorrect code? Reimar Döffinger
@ 2005-01-13 17:07 ` Takashi Iwai
  2005-01-18 20:15   ` Reimar Döffinger
  0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2005-01-13 17:07 UTC (permalink / raw)
  To: Reimar Döffinger; +Cc: alsa-devel

[-- Attachment #1: Type: text/plain, Size: 555 bytes --]

At Wed, 12 Jan 2005 12:23:20 +0100,
Reimar Döffinger wrote:
> 
> Hi,
> the attached code consumes more and more memory when I run it (with alsa
> 1.0.3 as included in SuSE 9.1).
> Why is that so? Did I forget to free something?
> Both commenting out the snd_mixer_selem_register or the snd_mixer_load
> call will fix it, but that's not an option in real code (this is
> actually a stripped-down version of the code in MPlayer's ao_alsa.c)...
> Any hints on that??

Yep, it hits a memory leak bug.
The patch below should fix it.


Takashi

[-- Attachment #2: Type: text/plain, Size: 465 bytes --]

Index: alsa-lib/src/mixer/bag.c
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-lib/src/mixer/bag.c,v
retrieving revision 1.4
diff -u -r1.4 bag.c
--- alsa-lib/src/mixer/bag.c	2 Jan 2002 12:01:22 -0000	1.4
+++ alsa-lib/src/mixer/bag.c	13 Jan 2005 16:53:44 -0000
@@ -59,6 +59,7 @@
 		bag1_t *b = list_entry(pos, bag1_t, list);
 		if (b->ptr == ptr) {
 			list_del(&b->list);
+			free(b);
 			return 0;
 		}
 	}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Memleak with mixer? Or incorrect code?
  2005-01-13 17:07 ` Takashi Iwai
@ 2005-01-18 20:15   ` Reimar Döffinger
  0 siblings, 0 replies; 3+ messages in thread
From: Reimar Döffinger @ 2005-01-18 20:15 UTC (permalink / raw)
  To: alsa-devel

Takashi Iwai <tiwai <at> suse.de> writes:
> At Wed, 12 Jan 2005 12:23:20 +0100,
> Reimar Döffinger wrote:
> > the attached code consumes more and more memory when I run it (with alsa
> > 1.0.3 as included in SuSE 9.1).
[...]
> > Any hints on that??
> 
> Yep, it hits a memory leak bug.
> The patch below should fix it.

Saw it is in CVS now. Thanks for fixing.

Greetings,
Reimar Döffinger




-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-01-18 20:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-12 11:23 Memleak with mixer? Or incorrect code? Reimar Döffinger
2005-01-13 17:07 ` Takashi Iwai
2005-01-18 20:15   ` Reimar Döffinger

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.