Parent-child ownership is a resource-management pattern in which a parent object controls the lifetime of its child objects. In Qt, each object can belong to a parent; destroying the parent automatically destroys the objects it owns. section 7.4.1
Apply the pattern with these safeguards:
- Assign ownership deliberately when creating child objects. section 7.4.1
- Ensure parents are eventually destroyed; a parent that remains alive retains every child indefinitely. section 7.4.1
- Use ownership-aware analysis to identify which parent prevented cleanup, rather than relying only on generic leak reports. section 7.4.1
Persistent Qt memory growth
A long-lived Qt parent accumulates child objects as the application runs. Memory usage grows because destroying the parent—the event that would automatically destroy those children—never occurs. Qt Creator's memory analysis can help identify the responsible parent. section 7.4.1
