Initial version of Heaptrack analyzer plugin
ClosedPublic

Authored by antonanikin on Mar 3 2017, 6:21 AM.

Details

Summary

Heaptrack is a fast heap memory profiler that runs on Linux. It allows you to track all heap memory allocations at run-time. Afterwards, the accompanying GUI tool can be used to find optimization opportunities in your code by analyzing the recorded profiling data. It allows you to:

  • Inspect peak heap memory consumption
  • Find memory leaks
  • Count overall number of memory allocations and find temporary allocations
  • Find small allocations with large overhead

You can use heaptrack pretty much wherever you are using Linux – it has been successfully used on 32bit and 64bit flavors of x86 and ARM platforms, both on embedded projects as well as desktop applications.

https://www.kdab.com/heaptrack-v1-0-0-release/
https://github.com/KDE/heaptrack/blob/master/README.md

Test Plan

Tested with kdevelop/kdevplatform master branch and heaptrack v1.0

Diff Detail

Repository
R32 KDevelop
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
antonanikin created this revision.Mar 3 2017, 6:21 AM

Current version has problem with job killing caused by heapcheck bug bug.

mwolff requested changes to this revision.Mar 5 2017, 8:02 PM

cool :)

analyzers/heaptrack/config/globalconfigpage.cpp
36

= default

analyzers/heaptrack/config/globalsettings.kcfg
11

it should default to heaptrack and be found in the PATH via QStandardPaths

15

dito

analyzers/heaptrack/job.cpp
135

instead of parsing it, we could add a patch to heaptrack to specify a path yourself, i.e. something like -o, and then you could use that here

This revision now requires changes to proceed.Mar 5 2017, 8:02 PM
antonanikin updated this revision to Diff 12224.Mar 6 2017, 4:25 AM
antonanikin edited edge metadata.
antonanikin marked an inline comment as done.
  • Use KDevelop::IRunController::showConfigurationDialog() method
  • Find executables via QStandardPaths
antonanikin marked 2 inline comments as done.Mar 6 2017, 4:26 AM
antonanikin added inline comments.
analyzers/heaptrack/job.cpp
135

Ok, it will be great. I'll fix this place after heaptrack upstream changes.

kfunk requested changes to this revision.Mar 7 2017, 9:34 PM
kfunk added a subscriber: kfunk.

Nice addition!

analyzers/heaptrack/CMakeLists.txt
4

Shouldn't be needed. Done via:

kde-modules/KDECMakeSettings.cmake
189:   set(CMAKE_INCLUDE_CURRENT_DIR ON)
analyzers/heaptrack/config/globalconfigpage.h
33

override

analyzers/heaptrack/debug.cpp
22

Please use "kdevelop.analyzers.heaptrack" instead (so we all share the same category prefix).

If possible please update the other analyzers as well.

analyzers/heaptrack/debug.h
24

KDEV_VERAPP -> KDEV_HEAPTACK

analyzers/heaptrack/job.cpp
155

This whole casing on e is already handled by OutputExecuteJob::childProcessError already, no? No need to duplicate code.

analyzers/heaptrack/plugin.cpp
120

This truncates a long int into an int (potentially losing information under Windows 64 bit).

Use a long int for Job::m_pid

135

qCDebug

analyzers/heaptrack/utils.h
28

executableName -> fallbackExecutableName?

analyzers/heaptrack/visualizer.cpp
38

Could capture and use error from the signal here.

63

Remove commented code

analyzers/heaptrack/visualizer.h
32

Should probably add some documentation that Visualizer does delete resultFile on destruction.

This revision now requires changes to proceed.Mar 7 2017, 9:34 PM
antonanikin updated this revision to Diff 12275.Mar 8 2017, 2:35 AM
antonanikin edited edge metadata.
  • Move tools actions into "Run" menu
antonanikin planned changes to this revision.Mar 8 2017, 2:35 AM
antonanikin marked 11 inline comments as done.Mar 9 2017, 2:34 AM

Kevin, thanks for detailed review!

analyzers/heaptrack/debug.h
24

Ooops :)

analyzers/heaptrack/job.cpp
155

Ok, you are right - we no need some special error processing code here.

antonanikin updated this revision to Diff 12314.Mar 9 2017, 2:34 AM
antonanikin marked 2 inline comments as done.
  • Fix inline comments
kfunk accepted this revision.Mar 9 2017, 8:52 AM

LGTM, let's just get this in to master as soon as possible.

Great work! Blog about it!

analyzers/heaptrack/job.h
41

int -> long int

analyzers/heaptrack/utils.cpp
31

Sorry, fallbackExecutablePath is better

antonanikin updated this revision to Diff 12318.Mar 9 2017, 9:17 AM
antonanikin marked an inline comment as done.
  • Fix inline comments
antonanikin marked an inline comment as done.Mar 9 2017, 9:17 AM
antonanikin added inline comments.
analyzers/heaptrack/job.h
41

Oops :)

  • Small UI fixes
This revision was automatically updated to reflect the committed changes.