Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPluginLoader Memory leaks?

QPluginLoader Memory leaks?

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 712 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    clarkb7
    wrote on last edited by
    #1

    Hi all,

    My application is using QPluginLoader, and valgrind is reporting memory leaks with QPluginLoader.

    @==5181== 604 (96 direct, 508 indirect) bytes in 1 blocks are definitely lost in loss record 167 of 216
    ==5181== at 0x4A08361: operator new(unsigned long) (vg_replace_malloc.c:298)
    ==5181== by 0x5C4DE11: ??? (in /opt/Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5.0.2)
    ==5181== by 0x5C42FD8: QPluginLoader::setFileName(QString const&) (in /opt/Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5.0.2)
    ==5181== by 0x5C448B0: QPluginLoader::QPluginLoader(QString const&, QObject*) (in /opt/Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5.0.2)
    ==5181== by 0x40911E: main_window_t::load_tools() (mainwindow.cpp:390)
    ==5181== by 0x40963A: main_window_t::main_window_t() (mainwindow.cpp:42)
    ==5181== by 0x4065BC: main (in /home/branden/Repositories/DR-GUI/bin/DR-GUI)@

    My code is

    @foreach (QString file_name, plugins_dir.entryList(QDir::Files)) {
    QPluginLoader loader(plugins_dir.absoluteFilePath(file_name), this);
    QObject *plugin = loader.instance();
    if (plugin != NULL) {
    tool_interface_t *i_tool;
    i_tool = qobject_cast<tool_interface_t *>(plugin);
    if (i_tool) {
    add_to_menu(plugin, i_tool->tool_names(),
    tool_menu, SLOT(add_tab()), tool_action_group);
    plugins.append(i_tool);
    }
    plugin_file_names += file_name;
    } else {
    QMessageBox::about(this, tr("About DR-GUI"),
    loader.errorString());
    }
    }@

    There are also memory leaks on QPluginLoader::instance.

    I am storing the _i_tool_s in the QVector plugins and deleting them in the destructor of main_window_t. plugin and i_tool point to the same memory loc, so I don't need to store & delete both, deleting it twice would be bad.

    The full source can be found on "github":https://github.com/clarkb7/DR-GUI
    Though I've updated it a little since I pushed it yesterday, it should still have these leaks.

    Any ideas? Thanks

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved