Commit a9093a20 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Do not keep unused plugins loaded after plugin scan

This saves about 20 Mb of address space, 10 Mb of memory on my system,
when the plugins cache is disabled. It is even more dramatic for
non-VLC apps (as then Qt4 is not loaded).
parent 103b4129
...@@ -970,38 +970,15 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank, ...@@ -970,38 +970,15 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank,
* Check our plugins cache first then load plugin if needed * Check our plugins cache first then load plugin if needed
*/ */
if( mode == CACHE_USE ) if( mode == CACHE_USE )
{
p_module = CacheFind( p_bank, path, mtime, size ); p_module = CacheFind( p_bank, path, mtime, size );
if( p_module != NULL )
{
/* For now we force loading if the module's config contains
* callbacks or actions.
* Could be optimized by adding an API call.*/
assert( !p_module->b_loaded );
for( size_t n = p_module->confsize, i = 0; i < n; i++ )
if( p_module->p_config[i].i_action )
{
DeleteModule( p_bank, p_module );
p_module = AllocatePlugin( p_this, path );
break;
}
}
}
if( p_module == NULL ) if( p_module == NULL )
{
p_module = AllocatePlugin( p_this, path ); p_module = AllocatePlugin( p_this, path );
if( p_module == NULL ) if( p_module == NULL )
return -1; return -1;
}
/* We have not already scanned and inserted this module */ /* We have not already scanned and inserted this module */
assert( p_module->next == NULL ); assert( p_module->next == NULL );
assert( !p_module->b_builtin );
/* Everything worked fine !
* The module is ready to be added to the list. */
p_module->b_builtin = false;
/* msg_Dbg( p_this, "plugin \"%s\", %s", /* msg_Dbg( p_this, "plugin \"%s\", %s",
p_module->psz_object_name, p_module->psz_longname ); */ p_module->psz_object_name, p_module->psz_longname ); */
...@@ -1009,6 +986,27 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank, ...@@ -1009,6 +986,27 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank,
p_bank->head = p_module; p_bank->head = p_module;
assert( p_module->next != NULL ); /* Insertion done */ assert( p_module->next != NULL ); /* Insertion done */
/* For now we force loading if the module's config contains
* callbacks or actions.
* Could be optimized by adding an API call.*/
for( size_t n = p_module->confsize, i = 0; i < n; i++ )
if( p_module->p_config[i].i_action )
{
if( !p_module->b_loaded )
{
DeleteModule( p_bank, p_module );
p_module = AllocatePlugin( p_this, path );
}
goto keep;
}
/* Unload plugin until we really need it */
if( p_module->b_loaded && p_module->b_unloadable )
{
module_Unload( p_module->handle );
p_module->b_loaded = false;
}
keep:
if( mode == CACHE_IGNORE ) if( mode == CACHE_IGNORE )
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment