GNOME Bugzilla – Bug 631064
Memory Usage increases considerably when using qtmux to record aac in mp4 format
Last modified: 2010-10-05 12:40:48 UTC
1) Record a file using qtmux for aac in mp4 format using pipeline gst-launch -e audiotestsrc wave=0 ! faac ! qtmux ! filesink location=test.mp4 & 2) Check the memory usage using top command, the memory usage keeps on increasing. 3) As far as I have understood, we are queuing buffer in gstqtmux.c:gst_qt_mux_add_buffer() and appending trak samples on to AtomSTBL holding different trak structures' GList by calling atoms.c:atom_add_trak_samples(). I have a vague idea that this is for getting the duration. [Please correct me if my understanding is wrong]. This can create problems in usecases where maximum heap size gets reached for example if we record for longer duration say 2-3 hours or even more. Thanks Kunal
I confirm. This leaks about 2MB/min. on my machine.
atoms.c:atom_add_trak_samples() indeed collects metadata for each buffer. However, it does not do so (anymore) using GList (but a more compact array instead). Also, it needs to keep track of more than simply durations (but also offsets, sizes, etc). This is a bit more than usually required for other formats, but still quite feasible. For instance, a typical AAC recording should use about 12 bytes per buffer, which amounts to give or take 36K/min. Next, "min(ute)" is relative in the above examples. Since the pipeline given above does not sync on the clock, it will run as fast as possible. That is, 1 minute of execution time leads to a sample file very much longer than 1 minute (in which case metadata may add up to quite a bit). Finally, running (e.g.) ---- valgrind --tool=massif gst-launch-0.10 -v audiotestsrc num-buffers=30000 samplesperbuffer=1024 ! audio/x-raw-int,rate=48000 ! faac ! mp4mux ! filesink location=test44.mp4 ---- shows only minor (expected) heap increase (for a give or take 10min recording).