Playing around with vld I came to the conclusion
that there is a memory leak in Qt's plugin system.

When I trace the allocations of Qt
(see ForceIncludeModules in the vld.ini file)
I get attached output after just opening and closing lyx.


It traces down to the macro in src/corelib/plugin/qplugin.h
(macro from 4.4, similar in 4.3.2):

#define Q_PLUGIN_INSTANCE(IMPLEMENTATION) \
        { \
            static 
QT_PREPEND_NAMESPACE(QPointer)<QT_PREPEND_NAMESPACE(QObject)> _instance; \
            if (!_instance)      \
                _instance = new IMPLEMENTATION; \
            return _instance; \
        }


After replacing this by the macro below, all leaks are gone.

#include <memory>
#define Q_PLUGIN_INSTANCE(IMPLEMENTATION) \
        { \
            static 
QT_PREPEND_NAMESPACE(QPointer)<QT_PREPEND_NAMESPACE(QObject)> _instance; \
            if (!_instance) { \
                 static std::auto_ptr<IMPLEMENTATION> _i0(new IMPLEMENTATION); \
                _instance = _i0.get(); \
                /*_instance = new IMPLEMENTATION;*/ \
            } \
            return _instance; \
        }

Is this by design or a candidate for the TT's TaskTracker?

Peter

Attachment: qt_memory_leak_report.txt.gz
Description: application/gzip

Reply via email to