Deeper insight of cpu and memory usage during development

Is there a way to get better insight of memory/cpu usage during development?

Given the overactive OOM-killer in SFOS I’d like to understand how changes I make to my program impact memory usage and if I could see it “live” broken down into what objects are in memory etc that would be even better (and CPU usage a cool bonus).

Yes I know that I can raise limits, but I can’t expect a normal user to enable developer mode, dive into a root shell and modify those limits.

4 Likes

Just off the top of my head, valgrind and memcheck can give you insight into memory usage. For c/c++ .
In qtcreator you have the analyze section with function and memory profiling using valgrind. and also QML profiler. On the command line you can run tests like:

valgrind --tool=callgrind harbour-appname. In qtcreator → Analyze-> Valgrind …

Have you tried these?

2 Likes

I just remembered that you have to install valgrind on the device first (zypper) if you want to use it from the ide. It’s mentioned in : https://forum.sailfishos.org/t/release-notes-sailfish-sdk-3-10

Sorry I didn’t add this is for python/QML applications not C/C++

1 Like

Ok, got ya. I haven’t done any profiling on the pythonic apps I maintain but perhaps @cypherpunks has an idea?

For code (not on sailfish yet) I have used cprofile from python3 The Python Profilers — Python 3.12.2 documentation to show me where / which function is time consuming. All of that depends on systat/pidstat if I remember correctly.

I haven’t used this for ever, but, for memory there is: tracemalloc — Trace memory allocations — Python 3.12.2 documentation

4 Likes

I had a vague memory and these two were in my bookmarks:

memory-profiler · PyPI (you use a @profile annotation to tell it what to examine)
GitHub - zhuyifei1999/guppy3: guppy / heapy ported to Python3. It works for real!

4 Likes