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. Qt and custom memory management
Forum Updated to NodeBB v4.3 + New Features

Qt and custom memory management

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 634 Views 3 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.
  • P Offline
    P Offline
    primem0ver
    wrote on last edited by primem0ver
    #1

    I have been researching this topic online and have been given the impression that it would not be easy and/or effective to incorporate custom memory management in a Qt application. This post is particularly alarming: https://stackoverflow.com/questions/25931668/does-qt-allready-have-its-own-new-and-delete-operators; though I am not sure how true its statements are (regarding PIMPL).

    Since the application I am building is complex, modular, and both memory, processor, and potentially gpu intensive, I really need to do my own memory management. I am currently leaning towards writing my own custom shared and smart pointers to do much of the memory management (especially for third party libraries) and it would help to get the facts straight. Is custom memory management possible and/or practical with Qt? Can I do this without rewriting the Qt code? If I did need to rewrite it, is there a particular set of base classes that would cover a large portion or would I need to effectively rewrite everything?

    kshegunovK 1 Reply Last reply
    0
    • P primem0ver

      I have been researching this topic online and have been given the impression that it would not be easy and/or effective to incorporate custom memory management in a Qt application. This post is particularly alarming: https://stackoverflow.com/questions/25931668/does-qt-allready-have-its-own-new-and-delete-operators; though I am not sure how true its statements are (regarding PIMPL).

      Since the application I am building is complex, modular, and both memory, processor, and potentially gpu intensive, I really need to do my own memory management. I am currently leaning towards writing my own custom shared and smart pointers to do much of the memory management (especially for third party libraries) and it would help to get the facts straight. Is custom memory management possible and/or practical with Qt? Can I do this without rewriting the Qt code? If I did need to rewrite it, is there a particular set of base classes that would cover a large portion or would I need to effectively rewrite everything?

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by kshegunov
      #2

      @primem0ver said in Qt and custom memory management:

      Is custom memory management possible and/or practical with Qt?

      Depends on what you mean by "custom memory management". If it means your own heap manager, then for sure it isn't practical.

      Can I do this without rewriting the Qt code?

      Not to any tangible result. With few exceptions Qt classes will new their own private data to keep binary compatibility. Thus even you write you own heap manager (which I really doubt the wisdom of) you're not going to get more than optimized void * allocation.

      If I did need to rewrite it, is there a particular set of base classes that would cover a large portion or would I need to effectively rewrite everything?

      Not sure, but it isn't trivial. The private classes inherit one another, QSharedData and QObject are starting points for investigation.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      3
      • P Offline
        P Offline
        primem0ver
        wrote on last edited by
        #3

        @kshegunov
        Thanks for the input. I am really curious why you feel I shouldn't write my own heap manager.

        1 Reply Last reply
        0
        • Kent-DorfmanK Offline
          Kent-DorfmanK Offline
          Kent-Dorfman
          wrote on last edited by
          #4

          @primem0ver said in Qt and custom memory management:

          Thanks for the input. I am really curious why you feel I shouldn't write my own heap manager.

          that isn't what he said. he said it wouldn't work well with the Qt framework. You can write whatever memory manager you like. simply override the default clib memory management functions and you can custom handle any memory the OS is willing to give you. however, if the framework is making certain "assumptions" about the state and capabilities of the heap then you WILL break something.

          1 Reply Last reply
          3
          • P Offline
            P Offline
            primem0ver
            wrote on last edited by
            #5

            If I was interested in testing my own build of Qt with my heap manager, how would I go about creating a custom build and setting my projects to use that build in Visual Studio using the plugin? Any pointers on where to get information on how to do this? I tried looking it up but could only find info on doing it with Qt Creator.

            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