mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 23:28:16 +00:00
allocator: add cleanup method
Make tracking memory leaks easier. https://bugzilla.gnome.org/show_bug.cgi?id=765212
This commit is contained in:
parent
57596ad48f
commit
1ea831bd6c
3 changed files with 23 additions and 2 deletions
|
@ -990,6 +990,7 @@ gst_deinit (void)
|
|||
gst_object_unref (clock);
|
||||
|
||||
_priv_gst_registry_cleanup ();
|
||||
_priv_gst_allocator_cleanup ();
|
||||
|
||||
#ifndef GST_DISABLE_TRACE
|
||||
_priv_gst_alloc_trace_deinit ();
|
||||
|
|
|
@ -127,6 +127,9 @@ G_GNUC_INTERNAL void _priv_gst_context_initialize (void);
|
|||
G_GNUC_INTERNAL void _priv_gst_toc_initialize (void);
|
||||
G_GNUC_INTERNAL void _priv_gst_date_time_initialize (void);
|
||||
|
||||
/* cleanup functions called from gst_deinit(). */
|
||||
G_GNUC_INTERNAL void _priv_gst_allocator_cleanup (void);
|
||||
|
||||
/* Private registry functions */
|
||||
G_GNUC_INTERNAL
|
||||
gboolean _priv_gst_registry_remove_cache_plugins (GstRegistry *registry);
|
||||
|
|
|
@ -536,7 +536,11 @@ default_free (GstAllocator * allocator, GstMemory * mem)
|
|||
static void
|
||||
gst_allocator_sysmem_finalize (GObject * obj)
|
||||
{
|
||||
g_warning ("The default memory allocator was freed!");
|
||||
/* Don't raise warnings if we are shutting down */
|
||||
if (_default_allocator)
|
||||
g_warning ("The default memory allocator was freed!");
|
||||
|
||||
((GObjectClass *) gst_allocator_sysmem_parent_class)->finalize (obj);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -573,7 +577,8 @@ void
|
|||
_priv_gst_allocator_initialize (void)
|
||||
{
|
||||
g_rw_lock_init (&lock);
|
||||
allocators = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
allocators = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
|
||||
gst_object_unref);
|
||||
|
||||
#ifdef HAVE_GETPAGESIZE
|
||||
#ifdef MEMORY_ALIGNMENT_PAGESIZE
|
||||
|
@ -592,6 +597,18 @@ _priv_gst_allocator_initialize (void)
|
|||
_default_allocator = gst_object_ref (_sysmem_allocator);
|
||||
}
|
||||
|
||||
void
|
||||
_priv_gst_allocator_cleanup (void)
|
||||
{
|
||||
gst_object_unref (_sysmem_allocator);
|
||||
_sysmem_allocator = NULL;
|
||||
|
||||
gst_object_unref (_default_allocator);
|
||||
_default_allocator = NULL;
|
||||
|
||||
g_clear_pointer (&allocators, g_hash_table_unref);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_memory_new_wrapped:
|
||||
* @flags: #GstMemoryFlags
|
||||
|
|
Loading…
Reference in a new issue