goom plugin mem leak patch

This forum is about all development around libVLC.
MichaelMc
Blank Cone
Blank Cone
Posts: 63
Joined: 10 Jun 2009 17:55

goom plugin mem leak patch

Postby MichaelMc » 10 Jun 2009 19:36

On Windows libgoom_plugin.dll, when enabled, generates a 2.5meg memleak when a track playback ends. A 2.5m per track leak. Problem is visible on VLC 0.9.x right through to current git master.

Here is a patch for vlc/modules/visualization/goom.c which works around the the failings of libgoom2k4 ability to free its resources.
Instead of creating a new instance of libgoom2k4 on each track start, with this patch a single instance will be used throughout.

Code: Select all

--- goom.c 2009-06-10 17:21:22.000000000 +0100 +++ mod_goom.c 2009-06-10 18:07:11.796875000 +0100 @@ -90,6 +90,10 @@ *****************************************************************************/ #define MAX_BLOCKS 100 #define GOOM_DELAY 400000 + +#ifdef WIN32 +static PluginInfo *p_plugin_info; +#endif typedef struct { @@ -326,7 +330,9 @@ audio_date_t i_pts; int16_t p_data[2][512]; int i_data = 0, i_count = 0; - PluginInfo *p_plugin_info; +#ifndef WIN32 + PluginInfo *p_plugin_info; +#endif int canc = vlc_savecancel (); width = var_GetInteger( p_this, "goom-width" ); @@ -335,8 +341,12 @@ speed = var_CreateGetInteger( p_thread, "goom-speed" ); speed = MAX_SPEED - speed; if( speed < 0 ) speed = 0; - - p_plugin_info = goom_init( width, height ); + +#ifdef WIN32 + goom_set_resolution(p_plugin_info, width, height); +#else + p_plugin_info = goom_init( width, height ); +#endif while( vlc_object_alive (p_thread) ) { @@ -375,8 +385,9 @@ p_pic->date = aout_DateGet( &i_pts ) + GOOM_DELAY; vout_DisplayPicture( p_thread->p_vout, p_pic ); } - +#ifndef WIN32 goom_close( p_plugin_info ); +#endif vlc_restorecancel (canc); return NULL; } @@ -448,3 +459,23 @@ return psz_title; } + +#ifdef WIN32 +BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved); + +BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + (void)hinstDLL; + (void)lpvReserved; + + if ( fdwReason == DLL_PROCESS_ATTACH ) + { + p_plugin_info = goom_init(320, 240); + } + else if ( fdwReason == DLL_PROCESS_DETACH ) + { + goom_close(p_plugin_info); + } + return 1; +} +#endif

Rémi Denis-Courmont
Developer
Developer
Posts: 15279
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: goom plugin mem leak patch

Postby Rémi Denis-Courmont » 10 Jun 2009 20:11

Please send patches to vlc-devel@v...org
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: goom plugin mem leak patch

Postby Jean-Baptiste Kempf » 11 Jun 2009 12:21

Yeah, that would be cool.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 52 guests