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. Good practices for memory gestion
Qt 6.11 is out! See what's new in the release blog

Good practices for memory gestion

Scheduled Pinned Locked Moved Unsolved General and Desktop
c++
2 Posts 2 Posters 243 Views 2 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.
  • Y Offline
    Y Offline
    Yoann LE BARS
    wrote on last edited by
    #1

    Hello everybody out there!

    There are several benchmarks analysing efficiency of different languages, tackling with very specific topics – loops, conditional branching, etc., – but I need a more general overview. Hence, I am creating a benchmark with a more general application and using a development framework.

    You guessed it, I have chosen Qt as the testing framework. I plan in creating the same application in several languages, being C++, Python, and Rust, as well as two versions mixing C++ with Python and Rust with Python. For now on, I have created the C++ and Python version :

    https://framagit.org/python-with-framework-benchmarking/pure-python
    https://framagit.org/python-with-framework-benchmarking/pure-cpp

    Here is the trouble: in the C++ version, memory liberation is slower than the Python version. I think I am doing something wrong, but I do not know what should be done. I try and make memory handling as safe, standard and automatic as possible, but I think there is something I did not understand in Qt memory handling.

    I am sorry, I cannot make a specific example, as I do not know what I am missing. Still, I have tried to document the code as much as possible and make it as readable as possible. If somebody can have a look and make me some advice, I guess it will be helpful.

    Best regards.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Without having dived in your source code, I think one key difference to take into account: Python is garbage collected while C++ is not.
      Also, deleting an object in C++ does not mean that the memory is immediately released to the OS. It may happen at different times depending on your application memory usage pattern, OS etc.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2

      • Login

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