Gstreamer & GLib memory management/profiling

Sergei Vorobyov sergei.vorobyov at facilitylabs.com
Fri Oct 31 08:34:15 PDT 2014


> I don't see why anything in GStreamer should be "incompatible" with that
> GLib API.

Neither do I. However, try a *FULL* program below:

// Compile with:
// gcc -std=c11 -Wall -pthread test.c -o test `pkg-config --cflags --libs
glib-2.0 gstreamer-1.0 gstreamer-pbutils-1.0 gstreamer-video-1.0`
// Run and enjoy

#include <stdio.h>
#include <stdlib.h>

#include <string.h>
#include <unistd.h>
#include <error.h>
#include <errno.h>
#include <math.h>

#include <glib.h>
#include <glib/gstdio.h>
#include <glib/gprintf.h>

#include <gst/gst.h>
#include <gst/pbutils/pbutils.h>
#include <gst/video/videooverlay.h>

int main(int argc, char** argv) {
    GError *e;
    g_mem_set_vtable (glib_mem_profiler_table);
    if (g_mem_is_system_malloc ())
        g_print ("system malloc is used\n");
    else
        g_print ("NOT system malloc is used\n");
    g_print ("********************* point 1\n");
    if (!gst_init_check (&argc, &argv, &e))
        g_print ("failed gst_init_check: %s\n", e->message);
    g_print ("********************* point 2\n");
    g_mem_profile ();
    return (EXIT_SUCCESS);
}

It produces, as expected:

fl at nuc5:~/NetBeansProjects/test$ ./test
NOT system malloc is used
********************* point 1

(test:3987): GLib-WARNING **: free(0x1a84fd0): memory has been freed
12297829382473034410 times already
*** Error in `./test': realloc(): invalid pointer: 0x0000000001a87e80 ***
Aborted (core dumped)


On Fri, Oct 31, 2014 at 2:20 PM, Tim Müller <tim at centricular.com> wrote:

> On Fri, 2014-10-31 at 13:46 +0100, Sergei Vorobyov wrote:
>
> Hi,
>
> > GLib's memory profiling seems incompatible with GStreamer. The
> > snippet:
>
> I don't see why anything in GStreamer should be "incompatible" with that
> GLib API.
>
> > extern GMemVTable *glib_mem_profiler_table;
> >
> >
> > gint main (gint argn, gchar** args) {
> >     GError *e;
> >     g_mem_set_vtable (glib_mem_profiler_table);
> >     if (g_mem_is_system_malloc ())
> >         g_print ("system malloc is used\n");
> >     else
> >         g_print ("NOT system malloc is used\n");
> >     g_print ("********************* point 1\n");
> >     if (!gst_init_check (&argn, &args, &e)) {
> >         g_print ("failed gst_init_check: %s\n", e->message);
> >     }
> >     g_print ("********************* point 2\n");
> >
> >     g_mem_profile ();
> >
> >
> >     ...
> >
> >
> > crashes at gst_init producing:
> >
> >
> > fl at nuc5:~/bin$ ./mp-v01.020
> > NOT system malloc is used
> > ********************* point 1
> >
> >
> > (mp-v01.020:15561): GLib-WARNING **: free(0x1b32fd0): memory has been
> > freed 12297829382473034410 times already
> > *** Error in `./mp-v01.020': realloc(): invalid pointer:
> > 0x0000000001b35e80 ***
> > Aborted (core dumped)
>
> I would guess this is just a bug somewhere (mixing glib and non-glib
> alloc/realloc/free API somewhere). Do you have a full stack trace from
> gdb?
>
> Cheers
>  -Tim
>
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20141031/32056f36/attachment.html>


More information about the gstreamer-devel mailing list