Results 1 to 6 of 6

Thread: Qt Plugins causing memory problems?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2014
    Posts
    9
    Thanks
    2

    Default Qt Plugins causing memory problems?

    Architecture of my project looks as follows:

    Main project, that is compiled as stand-alone application:
    TEMPLATE = app


    Sub projects, that are compiled as libraries:
    TEMPLATE = lib


    Plugins, that are compiled as Qt Plugins:
    CONFIG += plugin
    TEMPLATE = lib


    Common directory, that contains libs used by more than one element, f.e. all sub projects and one plugin.
    TEMPLATE = lib
    ---
    Main project accesses Sub projects as a libraries:
    INCLUDEPATH += \
    $$(SUB)/my_sub_pro1/lib \



    DEPENDPATH += \
    $$(SUB)/my_sub_pro1/lib \



    LIBS += \
    -L$$(BUILD_SUB)/lib -lmy_sub_pro1\



    Sub projects access plugins by using standard QPluginLoader. I'm checking all files in my plugin build directory and cast them:
    Qt Code:
    1. QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
    2. QObject *plugin = loader.instance();
    3. myPluginInterface* plugin = qobject_cast< myPluginInterface* > (plugin);
    To copy to clipboard, switch view to plain text mode 
    Any Main, Sub or plugin project that would like to use commons, is simply including them:

    SOURCES += \
    $$(COMMON)/common/calc.cpp



    HEADERS += \
    $$(COMMON)/common/calc.h

    ---

    I've got problem with my application crashing without reason on closing: It crashes in malloc.c: malloc_consolidate (Full stack below). This makes it incredibly hard to debug. I used Valgrind till the moment it doesn't show any memory leaks, but the problem persists. My friend once told me, that he had some problems while using static variables in plugins. I think he was right, because when I got rid of them me application is now crashing less often. I also had a small problem after adding a constexpr, but after some time the problem disappeared and I couldn't reproduce it.

    I cannot possibly paste all the code that might be causing problems. However I would like to sincerely ask for any idea that might cause problems on destruction in architecture that I'm using. I will be really thankful for any idea on what to check or what could be potential problems while creating program that is using a dynamic library that is using plugins. I couldn't find any similar topic on problems with Qt Plugins.

    It is worth to mention that crash only occurs on closing, and all destructors are called properly. What is more, when I created a stand-alone program that simply uses one Subprogram with plugins it works perfectly. Additionally if I use MainProgram to call any Subprogram without plugins it also works effortlessly. I'm using Qt 5.3.2.

    Stack view on crash:
    Qt Code:
    1. 0 malloc_consolidate malloc.c 5206
    2. 1 _int_free malloc.c 5079
    3. 2 QArrayData::deallocate 130
    4. 3 QTypedArrayData<int>::deallocate 234
    5. 4 QVector<int>::freeData 473
    6. 5 QVector<int>::~QVector 76
    7. 6 QRegExpEngine::~QRegExpEngine 1356
    8. 7 QCache<QRegExpEngineKey, QRegExpEngine>::clear 126
    9. 8 QCache<QRegExpEngineKey, QRegExpEngine>::~QCache 95
    10. 9 (anonymous namespace)::Q_QGS_globalEngineCache::Holder::~Holder 3825
    11. 10 __cxa_finalize cxa_finalize.c 56
    12. 11 __do_global_dtors_aux /opt/Qt-5.3.2/lib/libQt5Core.so.5
    13. 12 ??
    14. 13 _dl_fini dl-fini.c 254
    To copy to clipboard, switch view to plain text mode 
    Last edited by gavinmagnus; 2nd August 2017 at 15:03.

Similar Threads

  1. Replies: 3
    Last Post: 6th March 2014, 18:54
  2. When I use Listview with icons its causing memory leak
    By GuusDavidson in forum Qt Programming
    Replies: 4
    Last Post: 29th March 2011, 22:08
  3. Tracking memory consumption of plugins.
    By spud in forum General Programming
    Replies: 3
    Last Post: 7th September 2007, 13:14
  4. Problems loading static plugins
    By Rodrigo in forum Qt Programming
    Replies: 2
    Last Post: 11th July 2007, 12:42
  5. QT4 Plugins - problems, problems
    By NormanDunbar in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2006, 15:39

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.