Processor and RAM at Almost 100%Use!

I started recently to notice something very strange (for Linux in general).
I have 2 widgets in the tool bar showing me “Total CPU Use” and the other shows “Memory Usage”
I noticed that sometimes I find both showing almost 100% use of CPU and RAM!
My processor is Core i3, and have abuot 19GB RAM. My use is just normal use, browsing, playing YouTube videos in Chromium browser.

The only difference I had, is I just started a few days ago to play a little with Python and webscrapping with Python. I noticed this happens while my scripts was running but back to normal rates after the script finishes running.

I restarted a few times without running any of my scripts, but suddenly found CPU and RAM usage at almost 100% and couldn’t even close the browser or switch between tabs. The only thing I could do was ALT-printscreen REISUB to reboot!
This is my inxi

CPU: dual core Intel Core i3-10110U (-MT MCP-)
speed/min/max: 3932/400/4100 MHz Kernel: 6.1.20-1-lts x86_64 Up: 20m
Mem: 4681.1/19844.2 MiB (23.6%) Storage: 238.47 GiB (25.3% used) Procs: 242
System:
  Host: asus Kernel: 6.1.20-1-lts arch: x86_64 bits: 64 compiler: gcc
    v: 12.2.1 Desktop: KDE Plasma v: 5.27.3 tk: Qt v: 5.15.8 wm: kwin_x11 vt: 1
    dm: SDDM Distro: EndeavourOS base: Arch Linux
Machine:
  Type: Laptop System: ASUSTeK product: VivoBook_ASUSLaptop X415FAC_X415FA
    v: 1.0 serial: <superuser required>
  Mobo: ASUSTeK model: X415FAC v: 1.0 serial: <superuser required>
    UEFI: American Megatrends v: X415FAC.202 date: 07/08/2021

Can Python scripts run in the background on their own or anything Python related?
What might be causing this?
How to fix?

You should look at what is consuming the CPU/RAM when that happens with top, htop or similar.

1 Like

Thanks @dalto
I will see “htop”
I noticed something after I just did the “REISUB” reboot, the laptoop booted and Dolphin, Terminal and Firefox (multiple windows that seems were used by my script) opened by themselves though I did not run any Python script after last reboot and before this reboot. Same time I didn’t make any of these to boot on startup!

Here is my “htop” output:


    0[||||||||                                                                9.6%] Tasks: 119, 813 thr, 130 kthr; 1 running
    1[|||||||||                                                              11.0%] Load average: 0.85 1.07 0.73 
    2[|||||||||                                                              10.3%] Uptime: 00:08:08
    3[|||||||                                                                 9.0%]
  Mem[||||||||||||||||||||||||||||||||                                 3.43G/19.4G]
  Swp[                                                                       0K/0K]

  [Main] [I/O]
    PID USER       PRI  NI  VIRT   RES   SHR S  CPU%▽MEM%   TIME+  Command
   2774 limo        20   0 1131G  285M  152M S   9.0  1.4  0:20.07 /usr/lib/chromium/chromium --type=renderer --crashpad-handler-pid=2524 --enable-crash-reporter=,Arch
   2554 limo        20   0 33.7G  174M   97M S   5.8  0.9  0:14.62 /usr/lib/chromium/chromium --type=gpu-process --crashpad-handler-pid=2524 --enable-crash-reporter=,A
    721 limo        20   0 1712M  144M 99684 S   3.8  0.7  0:10.32 /usr/bin/kwin_x11 --replace
    600 root        20   0  398M 75224 53760 S   3.2  0.4  0:07.63 /usr/lib/Xorg -nolisten tcp -background none -seat seat0 vt1 -auth /var/run/sddm/{c089dcc4-b149-482d
   3986 limo        20   0 10128  6572  3760 R   3.2  0.0  0:01.59 htop
   2595 limo        20   0 33.7G  174M   97M S   1.9  0.9  0:04.75 /usr/lib/chromium/chromium --type=gpu-process --crashpad-handler-pid=2524 --enable-crash-reporter=,A
   3897 limo        20   0 1324M  185M  157M S   1.9  0.9  0:01.10 /usr/bin/konsole
   1198 limo       -21   0  146M 20924 14196 S   1.3  0.1  0:00.41 /usr/bin/pipewire
   2804 limo        20   0 1131G  285M  152M R   1.3  1.4  0:01.13 /usr/lib/chromium/chromium --type=renderer --crashpad-handler-pid=2524 --enable-crash-reporter=,Arch
   3888 limo        20   0 1131G  285M  152M S   1.3  1.4  0:01.03 /usr/lib/chromium/chromium --type=renderer --crashpad-handler-pid=2524 --enable-crash-reporter=,Arch
    731 limo        20   0 1712M  144M 99684 S   0.6  0.7  0:01.16 /usr/bin/kwin_x11 --replace
   1172 limo         9 -11 69364 34100  8528 S   0.6  0.2  0:00.56 /usr/bin/pipewire-pulse
   1544 limo        20   0 1962M  248M  137M S   0.6  1.3  0:01.11 /usr/bin/plasmashell --no-respawn
   2521 limo        20   0 33.6G  395M  229M S   0.6  2.0  0:28.93 /usr/lib/chromium/chromium
   2570 limo        20   0 33.4G  201M  161M S   0.6  1.0  0:10.88 /usr/lib/chromium/chromium --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-
   2776 limo        20   0 1131G  285M  152M S   0.6  1.4  0:02.45 /usr/lib/chromium/chromium --type=renderer --crashpad-handler-pid=2524 --enable-crash-reporter=,Arch
   2777 limo        20   0 1131G  285M  152M S   0.6  1.4  0:01.22 /usr/lib/chromium/chromium --type=renderer --crashpad-handler-pid=2524 --enable-crash-reporter=,Arch
   2805 limo        20   0 1131G  285M  152M S   0.6  1.4  0:01.20 /usr/lib/chromium/chromium --type=renderer --crashpad-handler-pid=2524 --enable-crash-reporter=,Arch
   2857 limo        20   0 1131G  227M  134M S   0.6  1.1  0:07.27 /usr/lib/chromium/chromium --type=renderer --crashpad-handler-pid=2524 --enable-crash-reporter=,Arch
   3078 limo        20   0 1137G  333M  120M S   0.6  1.7  0:27.90 /usr/lib/chromium/chromium --type=renderer --crashpad-handler-pid=2524 --enable-crash-reporter=,Arch
   3884 limo        20   0 33.5G  168M  151M S   0.6  0.8  0:00.48 /usr/lib/chromium/chromium --type=utility --utility-sub-type=audio.mojom.AudioService --lang=en-GB -
   3889 limo        20   0 1131G  285M  152M S   0.6  1.4  0:01.01 /usr/lib/chromium/chromium --type=renderer --crashpad-handler-pid=2524 --enable-crash-reporter=,Arch
   3890 limo        20   0 1131G  285M  152M S   0.6  1.4  0:01.03 /usr/lib/chromium/chromium --type=renderer --crashpad-handler-pid=2524 --enable-crash-reporter=,Arch
   3891 limo        20   0 1131G  285M  152M S   0.6  1.4  0:01.04 /usr/lib/chromium/chromium --type=renderer --crashpad-handler-pid=2524 --enable-crash-reporter=,Arch
      1 root        20   0  163M 13392 10176 S   0.0  0.1  0:00.92 /usr/lib/systemd/systemd --switched-root --system --deserialize 31
F1Help  F2Setup F3SearchF4FilterF5Tree  F6SortByF7Nice -F8Nice +F9Kill  F10Quit  

That sounds like you may want to recheck your script.

1 Like

What to check in the script? It could be run only through the command

python myscript.py

and it has nothing to do with running anything on boot.
It just tries to open a few websites, copy their content to a local file. That;s all.
What to check in my script?

I know absolutely nothing about scripts. I’ve never even written one.

But if you use them, and that looks like remnants from it, that’s a logical place to look.

You need to run that when the high utilization is occurring. It will tell you what process(es) are consuming the resources so you know where to look.

This is one of the most exhausting tasks you can do, by personal experience. :wink:

1 Like

:thinking:
Maybe.
I just made a copy of the folders containing the new scripts to an external USB, and deleted them from my drive.
I will see how it goes.
UPDATE:
Updated system, rebooted normally, then “REISUB” and it rebooted normally!
It is weird!
The scripts has nothing to make them run in the background!
I do not know if this code to terminate the script is correctly terminating it:

Step 7: End the running of the script
logging.info("Done!")

Maybe this needs to be modified? It is the last command in the script.

htop does not recognize my executable test-script running with over 90%+ CPU effort, but top can.
Just use top instead.

Thanks @Zesko
As I said I removed all the scripts.
So far so good!
But I couldn’t understand how an script(s) that are not running cause this!

Unless your system is one of those with ghosts :ghost: , some program’s configuration is responsible for this, which only you can find :person_shrugging: .

2 Likes

$ htop

image

5 Likes

Yes. agree with you. It happens only with this Python script that ends with

Step 7: End the running of the script
logging.info("Done!")

It does not terminate the app explicitly. Though I am not sure as I assume it should end as it reaches the last command. Unless something in the scripts keeps running forever after being called from the script! I will look at the code again.
Thank you all for your inputs.
P.S. Please accept my apology for late reply as I just got busy.

1 Like

In bash, it terminates at the end of the script, but… this is not bash :wink:
I can only handle one programming language at a time (currently bash), so I cannot help :person_shrugging:

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.