[fpc-pascal] How to find where my app consumes CPU?

Bo Berglund bo.berglund at gmail.com
Tue May 18 22:37:54 CEST 2021


On Tue, 18 May 2021 21:59:33 +0200, Bo Berglund via fpc-pascal
<fpc-pascal at lists.freepascal.org> wrote:

>This is working seemingly OK, but today when I checked the RPi I found using top
>that it was running 11% CPU, which is strange because it has nothing to do at
>the moment.
>
>I have tried to be as conservative as possible regarding wait loops etc so in
>such loops I always have a sleep() call, which in my Windows experience used to
>stop excessive CPU usage.
>
>So I was surprised to find the high CPU usage and now I am at a loss on how to
>find *where* this is happening...

This is what top displays:

top - 15:34:13 up 10 days, 12:46,  2 users,  load average: 0.10, 0.04, 0.14
Tasks: 142 total,   1 running, 141 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.6 us,  0.6 sy,  0.0 ni, 98.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :    924.2 total,    279.1 free,    523.7 used,    121.4 buff/cache
MiB Swap:   2048.0 total,   1495.2 free,    552.8 used.    340.2 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
15283 pi        20   0   51764   7948   6260 S   6.3   0.8   3:00.16
SSRemoteServerL
26357 pi        20   0   10436   2968   2516 R   1.0   0.3   0:01.66 top

PID 15283 is my service application.
It now runs at about 6% all the time, but when I discovered the problem it was
running at 10.5% CPU.
After I restarted the service it dropped to 6% or thereabouts.


-- 
Bo Berglund
Developer in Sweden



More information about the fpc-pascal mailing list