After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 509559 - [gstinfo]_gst_debug_init() memory leak
[gstinfo]_gst_debug_init() memory leak
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
0.10.16
Other Linux
: Normal normal
: 0.10.18
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-01-15 07:46 UTC by Jason Zhao
Modified: 2008-02-05 20:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gstinfo.c patch (155 bytes, patch)
2008-01-15 07:47 UTC, Jason Zhao
none Details | Review
new patch with "diff -u" (601 bytes, patch)
2008-01-16 01:28 UTC, Jason Zhao
none Details | Review
Don't allow gst_init() to be called after gst_deinit() (947 bytes, patch)
2008-01-16 19:25 UTC, David Schleef
committed Details | Review

Description Jason Zhao 2008-01-15 07:46:25 UTC
gst debug has no deinit() funtion, if application invokes
while()
{
gst_init()
gst_deinit()
}
It will cause _gst_debug_init() memory leak and multiple output per log.
In gst_init(), it invokes _gst_debug_init(), but _gst_debug_init() has no check for "initalized", it will new many debug categories every time, that will cause memory leak, and after that, if we want to output a log, this log will be printed many times.

Changed files:
gst/gstinfo.c

Motorola would like to contribute gstreamer patch to the  gstreamer open source
community project. Please find attached the patch applicable for gstreamer. For
any questions, please feel free to contact (Zhao Liang "e3423c@motorola.com",
Shi Ling "w20230@motorola.com").
Comment 1 Jason Zhao 2008-01-15 07:47:11 UTC
Created attachment 102885 [details] [review]
gstinfo.c patch
Comment 2 David Schleef 2008-01-15 17:19:02 UTC
Please create patches using diff -u
Comment 3 David Schleef 2008-01-15 17:21:06 UTC
Also, being able to call gst_init() after calling gst_deinit() is not a goal.  gst_deinit() is only supposed to be called when exiting a process, mainly for memory leak checking.
Comment 4 Jason Zhao 2008-01-16 01:27:23 UTC
I think it could not be restricted that application must calls gst_deinit when it want to exit, because maybe the application just wants to a few functions from gstreamer, and after that, all gstreamer resource should be removed.
In current implementation, many global variables are used, but no deinit() for gst debug, I think if we don't check whether it is already initialized, it will cause memory leak and abnormal log output. We could not expect application can do it well.
Comment 5 Jason Zhao 2008-01-16 01:28:10 UTC
Created attachment 102954 [details] [review]
new patch with "diff -u"
Comment 6 David Schleef 2008-01-16 19:25:41 UTC
Created attachment 103014 [details] [review]
Don't allow gst_init() to be called after gst_deinit()

The bug is that gst_deinit() makes it possible for gst_init() to be called again.  Patch fixes this.
Comment 7 Jason Zhao 2008-01-17 02:36:50 UTC
By your patch, I think gstreamer can be considered as a resident library, when application use it, all the resources can not be released untill exiting application.

I find not only gst debug but also gst_event, gst_buffer, gst_message, gst_tag all have no deinit, even in gst_deinit, these resources are not be released. Is it right?
Comment 8 Julien MOUTTE 2008-01-22 13:04:37 UTC
Can you provide a concrete use case of an application that would initialize GStreamer and then deinitialize it to remove those resources ?

[This bug is part of Fluendo support for Motorola.]
Comment 9 Jason Zhao 2008-01-23 01:16:50 UTC
For example, Multimedia message application, it is often a daemon process, so no much resources expense are expected when it is idle, but if we want to use gstreamer do multimedia playback, it would alway occupy much memory even it is free.
By my investigation, current gstreamer lets OS to release all resources when do exit. even in gst_deinit, no all resources are released.
Comment 10 David Schleef 2008-02-05 18:50:56 UTC
2008-02-05  David Schleef  <ds@schleef.org>

        * gst/gst.c: Add a separate gst_deinitialized that prevents
          gst_init() from being called after gst_deinit().  Fixes #509559

It's pretty clear from discussions on IRC that none of the core developers think we should support multiple init/deinit cycles.  It's not how gstreamer, gobject, or glib is designed.