[Interest] QPluginLoader

Konrad Rosenbaum konrad at silmor.de
Wed Apr 19 10:15:58 CEST 2017


On Wed, April 19, 2017 08:30, Igor Mironchik wrote:
> In the docs to QPluginLoader:
>
> Once loaded, plugins remain in memory until all instances of
> QPluginLoader <qpluginloader.html> has been unloaded, or until the
> application terminates.
>
> But in plugandpaint example:
[cut]
> So my question is why plugins keep alive when QPluginLoaders' will be
> destructed?
>
> Or in Qt somewhere is static global QPluginLoader that keeps all plugins
> alive? Or something yet?

The documentation is a bit ambiguous and outdated it seems.

The behavior changed a few versions ago: plugins stay in memory unless you
explicitly call unload() on all instances of QPluginLoader that reference
this plugin.

This happens to prevent crashes that unfortunately were rather frequent
when plugins/libraries were unloaded while there were still objects
referencing symbols from those plugins/libraries.

In 99.9% of all cases it does not hurt to keep a library in memory: if
there is memory pressure the OS's memory management knows to discard the
pages and later to reload them from the library.

There are only EXTREMELY rare cases in which it is necessary for ordinary
users to reload libraries with a different version while the program keeps
running.



    Konrad




More information about the Interest mailing list