Results 1 to 6 of 6

Thread: Qt Plugins causing memory problems?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,349
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: Qt Plugins causing memory problems?

    You are chasing a red herring here. There is no way I can see in which the build configuration of your project could have any effect on the runtime behavior except to cause errors in linking if you are somehow linking the same code more than once into a single binary (exe or dll). And if you get errors in linking, the exe or dll won't be built.

    If you have common source code that is built into more than one binary, then you should isolate this code into its own static library and link that with each binary that needs it. But again, compiling and linking the same source code into different binaries should still not cause problems unless you are defining global variables or static member variables in classes in that code that end up being instantiated more than once.

    If you are moving code around and are seeing crashes in different places, then I would say that something in your code is corrupting memory. It is a classic sign when a program crashes in a piece of code you aren't even aware you are using. The location of the crash is not the cause of the crash, it is just where the program tries to do something with the corrupted memory and goes off into limbo.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: Qt Plugins causing memory problems?

    After commenting all sections using QVector<int> I have successfully isolated the problem. It looks like the problem occurs when I was using common directory like this: Sub project was using the same common sources + headers as plugin:
    like d_stranz, I don't see the connection between QVector<int> and your project configuration.
    If the linker didn't complain about multiple definition of symbols that is NOT your problem.

    Right now I'm getting a little more difficult problem: it crashes in QVector< QCustomTypeInfo >
    This reinforces my original suspicion - that somewhere you you are deleting a vector not as you should.
    My guess is, that you have pointer to such a vector (or possible multiple pointers) which get destroyed and leave a dangling pointer behind, which then again gets deleted - but that can't work of course.
    This is of course pure speculation.
    Again, without the code one can only guess.
    Can you say in which object this crashes?
    My guess this is a moc file.
    Are you passing any vectors per signal slots?
    Then its almost certainly the case.

    I just thought I cannot paste thousands lines of code and ask for a debugging.
    No need, just the places you either delete or have QVectors going out of scope.
    Can't be THAT many.

    Try building your application and plugins as a debug build, and run it from the debugger - this will save us all the guess work and show you exactly where the crashing line is.

    And beyond that - the best thing you can do to fix this and make sure you fix many other problems you don't even know you have is write tests for your code - it will show you where you have problems and help you localize them.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

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.