Question about memory leak with speex and nframes > 1
Eric de Jong
ericdejong_nospam10 at gmx.net
Tue Feb 2 12:48:51 CET 2016
Question about memory leak with speex and nframes > 1
Who can help me with the following problem? When I use the speex decoder
and decode a speex stream with nframes > 1, memory is leaked and the
application will crash after a day.
My system: Windows 8.1 32bit, Dell optiplex 780, Core2Duo E7500, 4GB ram
I installed gstreamer-1.0-x86-1.6.3.msi with the following:
GStreamer 1.0 core
GStreamer 1.0 system plugins
GStreamer 1.0 plugins for playback
GStreamer 1.0 codecs
GStreamer 1.0 plugins for capture
Then I run the following batch file, mytest.bat:
SET PATH=c:\gstreamer\1.0\x86\bin\;%PATH%
gst-launch-1.0 autoaudiosrc ! audioconvert ! speexenc nframes=10
mode=3 quality=5 ! speexdec ! autoaudiosink > NULL
The memory leak is visible in taskmgr.exe after about 23 minutes. As
gstreamer does initially allocates 22MB I guess this hides the
increasing memory usage in taskmgr earlier.
The amount of memory leaked is dependent on nframes.
In my application (not the command line above but similar) I have a
separate speex encoder and decoder. In the decoder I can see the following:
With nframes=1, no memory is leaked.
With 'nframes=2' memory is leaked, and with 'nframes=10' more memory is
leaked.
I do not have exact figures, but it looks like that for every
'nframes-1' a memory leak of about 420 bytes occurs. (only for the first
frame the memory is freed)
Note that in my test every frame generates a 320 bytes raw audio packet,
as speex decodes the stream into 16bit 8kHz mono with 50 frames/second.
With nframes > 1 I receive the following warning for every decoded frame:
WARNING: from element /GstPipeline:pipeline0/GstSpeexDec:speexdec0:
received more decoded frames 1 than provided 0
Additional debug info:
gstaudiodecoder.c(1343): gst_audio_decoder_finish_frame ():
/GstPipeline:pipeline0/GstSpeexDec:speexdec0
In the following test I can get more information:
mytest.bat:
SET PATH=c:\gstreamer\1.0\x86\bin\;%PATH%
SET GST_DEBUG_FILE=_debug.txt
SET GST_DEBUG=GST_MEMORY:7,speexdec:7
gst-launch-1.0 autoaudiosrc ! audioconvert ! speexenc nframes=10
mode=3 quality=5 ! speexdec ! autoaudiosink
In the generated _debug.txt file, I can see that every allocated buffer
I checked it has a matching 'free'. So no help here.
In gstspeexdec.c I see the following (very simplified!) loop:
/* now decode each frame, catering for unknown number of them (e.g.
rtp) */
for (i = 0; i < fpp; i++) {
GstBuffer *outbuf;
outbuf =
gst_buffer_new_allocate (NULL,
dec->frame_size * dec->header->nb_channels * 2, NULL);
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
ret = speex_decode_int (dec->state, bits, (spx_int16_t *) map.data);
gst_buffer_unmap (outbuf, &map);
res = gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (dec),
outbuf, 1);
}
Here it seems to me 'gst_audio_decoder_finish_frame' accepts and plays
every frame.
Who can help me or point me in the proper direction?
Best regards, Eric de Jong
More information about the gstreamer-devel
mailing list