Object property memory management



  • Hi,

    If I have some object, Item or QtObject as a property of a QML element (let's say Item as the container, but I am also interested in the situation, when the containing object is QtObject), how is the memory management done?

    Think about these following situations:

    1:    property var someObject: { "key" : "value" }
    
    2:    property Item someItem: Item { ... }
    
    3:    property QtObject someQtObject: QtObject { ... }
    

    Will the containing element be the objects' parent? Will the memory of the property object be released, when the parent gets destroyed? Is this actually not a good thing to do, and might lead to memory leaks, unless the properties are deleted or released in code? And so on. Any insights?

    Also, would it be beneficial to do something like this:

    4:    property Item someItem: Item {
               parent: containingElementId
               ...
          }
    

    I have sometimes the need to do things such as here, and not simply configure the object to be under the children default property of an item. Also, when the containing object is QtObject, there is no children default property, but memory still needs to be managed.

    Thanks,
    -A888


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.