Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Memory Management in Qt/C++
Forum Updated to NodeBB v4.3 + New Features

Memory Management in Qt/C++

Scheduled Pinned Locked Moved Language Bindings
8 Posts 3 Posters 4.7k 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.
  • G Offline
    G Offline
    Gwal Ashish
    wrote on last edited by
    #1

    Hello,

    I am currently developing a GUI front-end application for DVR(Digital Video Recording). After completing the coding part of it, I have tested it many times and it is working fine but I want to it to be more robust. For that I looked into memory management part of it. Then I have tested my code binary with the valgrind tool which is the ultimate memory leak tester. I found 63 errors in my code after testing with valgrind. I have went thorough output of the valgrind but not able to understand how it was working and telling actually where is the error. I am totally confused. Do not know from where to start.

    I have also studied about some memory management technique likes of manually deletion of the object which we have created using "delete <object_name>" command but that is not helping me.

    Please guide me because this is my first production level program and I do not have any knowledge about memory management in qt. So please help me.

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hpollak
      wrote on last edited by
      #2

      There are some good tutorials for Valgrind. Take a look to

      "CProgramming / Debug / Valgrind":http://www.cprogramming.com/debugging/valgrind.html
      "Valgrind: Quick-Start":http://valgrind.org/docs/manual/quick-start.html
      "Valgrind: FAQ":http://valgrind.org/docs/manual/faq.html

      1 Reply Last reply
      0
      • H Offline
        H Offline
        hpollak
        wrote on last edited by
        #3

        An other good article:

        "Linuxprogrammingblog":http://www.linuxprogrammingblog.com/using-valgrind-to-debug-memory-leaks

        1 Reply Last reply
        0
        • G Offline
          G Offline
          Gwal Ashish
          wrote on last edited by
          #4

          Is use of smart pointers will be useful for memory management ?

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giesbert
            wrote on last edited by
            #5

            Hi Gwal Ashish,

            smart pointer help with memory management if they are managing smart pointers (not like QPointer shich keeps track if the object behind exists).

            In QObject hierarchies (parent / child) all children will automatically be deleted, so no need of smart pointers here, but the top level elements must be deleted manually.

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            1 Reply Last reply
            0
            • G Offline
              G Offline
              Gwal Ashish
              wrote on last edited by
              #6

              [quote author="Gerolf" date="1355130051"]Hi Gwal Ashish,

              smart pointer help with memory management if they are managing smart pointers (not like QPointer shich keeps track if the object behind exists).

              In QObject hierarchies (parent / child) all children will automatically be deleted, so no need of smart pointers here, but the top level elements must be deleted manually.[/quote]

              Hi Gerolf,

              I have understanding about QObject hierarchies but as you suggested in your post that I have to delete top level element manually then what approach should be useful in our thinking. Please suggest me something to start with then I will try to implement.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                giesbert
                wrote on last edited by
                #7

                e.g. in Main, you can create the widgets on the stack.
                If you have top level QObjects elsewhere where the stack is not possible, use smart pointers like shared pointers or others.

                Nokia Certified Qt Specialist.
                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  Gwal Ashish
                  wrote on last edited by
                  #8

                  [quote author="Gerolf" date="1355228848"]e.g. in Main, you can create the widgets on the stack.
                  If you have top level QObjects elsewhere where the stack is not possible, use smart pointers like shared pointers or others.[/quote]

                  Hi Gerolf,

                     Will you please give me some example related this to study because everything which is related to memory leak is going over my head. So it would be nice to have some example to go through and then decide how to about memory leaks.
                  
                  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