Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#286 memory consumption increase

open
nobody
None
5
2005-04-20
2005-04-20
finski
No

Hello!
I have dvbTV-card without mpeg-encoder so I have to use
softdevice plugin with vdr. Softdevice plugin use the
ffmpeg to encode ps to mpeg2. After while softdevice
craches if the TV signal is not perfect.
When I started to look closer to ffmpeg I noticed that
with this source signal (ps) ffmpeg makes av_realloc
bigger and bigger all the time until there is not
memory available any more.
min_size parameter is bigger and bigger...
#0 av_realloc (ptr=0xb7990008, size=622308) at mem.c:117
#1 0x080a8af8 in av_fast_realloc (ptr=0xb7990008,
size=0x832d658,
min_size=585672) at utils.c:88
#2 0x0805f338 in av_add_index_entry (st=0x832d318,
pos=317622258,
timestamp=1871372296, distance=0, flags=0) at
utils.c:1022
#3 0x080677bb in mpegps_read_pes_header (s=0x832c3a8,
ppos=0xbfffec28,
pstart_code=0xbfffec4c, ppts=0xbfffec38,
pdts=0xbfffec30) at mpeg.c:1485
#4 0x0806781f in mpegps_read_packet (s=0x832c3a8,
pkt=0x832d2b8)
at mpeg.c:1504
#5 0x0805e28e in av_read_packet (s=0x832c3a8,
pkt=0x832d2b8) at utils.c:585
#6 0x0805eee1 in av_read_frame_internal (s=0x832c3a8,
pkt=0xbfffed50)
at utils.c:856
#7 0x0805f099 in av_read_frame (s=0x832c3a8,
pkt=0xbfffed50) at utils.c:921
#8 0x080581f1 in av_encode (output_files=0x82cb640,
nb_output_files=1,
input_files=0x82cb540, nb_input_files=1,
stream_maps=0x82cb6a0,
nb_stream_maps=0) at ffmpeg.c:1893
#9 0x0805cddf in main (argc=6, argv=0xbffff284) at
ffmpeg.c:4205
(gdb)

min_size comes from av_add_index_entry function:
entries = av_fast_realloc(st->index_entries,

&st->index_entries_allocated_size,
(st->nb_index_entries + 1) *
sizeof(AVIndexEntry));
The problem is st->nb_index_entries which is increasing
all the time.
I made patch in ffmpeg.c in av_encode function at line
1915:

/* read a frame from it and output it in the fifo */
is = input_files[file_index];
if (av_read_frame(is, &pkt) < 0) {
file_table[file_index].eof_reached = 1;
if (opt_shortest) break; else continue; //
}

/* MY PATCH START */
for( i=0;i<is->nb_streams;i++) {
is->streams[i]->nb_index_entries=0;
}
/* MY PATCH END */

if (!pkt.size) {
stream_no_data = is;

So the patch sets nb_streams parameter to 0 after frame
read.

Another patch I made was to put flush to "1" in function
av_interleaved_write_frame:
int ret= av_interleave_packet(s, &opkt, pkt, 1);//
<-------FLUSH=1

When I checked the result of this with memprof it
looked that memory use is now at same level all the
time. Not increasing.

I dont know any details of ffmpeg so I hope if somebody
else will check these proposes.

I use latest ffmpeg cvs version. SuSe linux 9.2.

Discussion

  • This Sourceforge bug tracker here has been abandoned many years ago.

    Our new tracker can be found through http://www.ffmpeg.org/bugreports.html