1

I am using QtCore, QtGUI, QtWidget with C++ and would need to track memory allocations to fix huge performance issues in my project. I have custom tracking mechanism, but would need to override malloc/new for the internal allocations that Qt does. Googled for a malloc hook or callback or something like that that Qt provides, but couldn't find. Can anyone tell me if there is a direct way to inform Qt to use custom allocators?

CJCombrink
  • 3,738
  • 1
  • 22
  • 38
Swtsvn
  • 315
  • 2
  • 13
  • what platform are you on? valgrind is the standard for unix based setups. – phyatt Dec 08 '15 at 21:28
  • QT is QuickTime, Qt is the C++ library, please make sure to use the correct one when referring to the C++ library. – CJCombrink Dec 09 '15 at 05:46
  • Can't you use something like Valgrind/Callgrind (linux) or another profiling tool to find such issues without having to create custom allocators? – CJCombrink Dec 09 '15 at 05:55
  • Rather than implmenting your own allocator, you should think about using Qt Smart Pointers: https://wiki.qt.io/Smart_Pointers – Claudio Dec 09 '15 at 08:19

1 Answers1

1

I would try to define own debug new and delete operators. There is a relative question for that: Does Qt allready have its own new and delete operators? I can trust the answer from there and the task is about redefining C++ own operators then.

But mind that we want global scope operators covering all C++ allocations: How to properly replace global new & delete operators

Community
  • 1
  • 1
Alexander V
  • 8,351
  • 4
  • 38
  • 47