D7107: Move QMenu allocation from heap to stack

Denis Kurz noreply at phabricator.kde.org
Fri Aug 11 08:57:10 BST 2017


dkurz added a comment.


  So now we have readability, memory safety and performance on the plus side. To further back my performance claim, [1] investigates the difference between stack and heap allocation. Short answer: depends on the platform, but stack allocation can easily be faster by two orders of magnitude for a simple single-threaded program. KMail is multithreaded, so we can expect bigger differences: Heap allocation causes threads to synchronize on most platforms, because the heap is a shared resource (see e.g. [2]). The kind of allocation also hints at the expected lifetime of an object (in C++; in Qt, this is somewhat questionable).
  
  [1] https://stackoverflow.com/questions/161053/which-is-faster-stack-allocation-or-heap-allocation
  [2] https://stackoverflow.com/questions/1665419/do-threads-have-a-distinct-heap

REPOSITORY
  R206 KMail

REVISION DETAIL
  https://phabricator.kde.org/D7107

To: dkurz, #kde_pim_kmail
Cc: dvratil, mlaurent, #kde_pim, dvasin, winterz, vkrause, knauss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20170811/a7267813/attachment.html>


More information about the kde-pim mailing list