glbasememory: Free the actual memory object when requested
authorMatthew Waters <matthew@centricular.com>
Thu, 7 Jan 2016 09:56:54 +0000 (20:56 +1100)
committerMatthew Waters <matthew@centricular.com>
Mon, 11 Jan 2016 09:40:39 +0000 (20:40 +1100)
Otherwise we are leaking ~400B on each GstMemory allocation.

Freeing in the base class matches the GObject semantics.

gst-libs/gst/gl/gstglbasememory.c
gst-libs/gst/gl/gstglmemorypbo.c

index dbc756e..4f70017 100644 (file)
@@ -442,6 +442,8 @@ _mem_free (GstAllocator * allocator, GstMemory * memory)
     mem->notify (mem->user_data);
 
   gst_object_unref (mem->context);
+
+  g_free (memory);
 }
 
 /**
index 37fe85a..8e8bbb8 100644 (file)
@@ -236,7 +236,7 @@ _gl_mem_new (GstAllocator * allocator, GstMemory * parent,
     GDestroyNotify notify)
 {
   GstGLMemoryPBO *mem;
-  mem = g_slice_new0 (GstGLMemoryPBO);
+  mem = g_new0 (GstGLMemoryPBO, 1);
   mem->mem.texture_wrapped = FALSE;
 
   _gl_mem_init (mem, allocator, parent, context, target, params, info, plane,
@@ -657,12 +657,6 @@ _gl_mem_destroy (GstGLMemoryPBO * gl_mem)
           *) gl_mem);
 }
 
-static void
-_gl_mem_free (GstAllocator * allocator, GstMemory * mem)
-{
-  GST_ALLOCATOR_CLASS (parent_class)->free (allocator, mem);
-}
-
 static GstGLMemoryPBO *
 _gl_mem_pbo_alloc (GstGLBaseMemoryAllocator * allocator,
     GstGLVideoAllocationParams * params)
@@ -722,7 +716,6 @@ gst_gl_memory_pbo_allocator_class_init (GstGLMemoryPBOAllocatorClass * klass)
   gl_base->destroy = (GstGLBaseMemoryAllocatorDestroyFunction) _gl_mem_destroy;
 
   allocator_class->alloc = _gl_mem_alloc;
-  allocator_class->free = _gl_mem_free;
 }
 
 static void