[Interest] Create the main widget on heap in main()

Constantin Makshin cmakshin at gmail.com
Sat Jan 11 14:45:21 CET 2014


It may be useful to remind that while the OS will destroy the process'
heap, it won't call any destructors (simply because it knows nothing about
them), creating a non-zero chance that some resources may not be cleaned up
properly.
On Jan 11, 2014 4:54 PM, "Till Oliver Knoll" <till.oliver.knoll at gmail.com>
wrote:

> Am 11.01.2014 um 13:30 schrieb Etienne Sandré-Chardonnal <
> etienne.sandre at m4x.org>:
>
> 2014/1/11 Constantin Makshin <cmakshin at gmail.com>
>
>> True, but why would one need a parented object in main()? :-)
>>
>
> True, but an object that should be deleted at the last line of main but is
> not by mistake is a non-leak :)
>
>
> Technically it is.
>
> The process heap is deleted anyway...
>
>
> The OS is just kind enough to sweep it under the rug. It won't make it
> easier to find "real" leaks with tools, because your developers will tend
> to say the same: "It's not a leak, it's cleared by the OS anyway..."
>
> I've seen already several crashes due to QObjects on stack and double
> deletions, I just want to point this out...
>
>
> Fix the double-deletes instead - those are real issues! If an object is
> double-deleted it might be an indication that it should not have been
> allocated on the stack in the first place...
>
> Cheers,
>   Oliver
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140111/76caaf23/attachment.html>


More information about the Interest mailing list