micro icon indicating copy to clipboard operation
micro copied to clipboard

micro eats all my CPU resources by reopening dead instances as zombie threads

Open evanescente-ondine opened this issue 1 year ago • 3 comments

For months, micro has been constantly reopening threads of closed instances and eating all my CPU's attention. Does someone have a similar problem ? If not, I'll have to remove switch for another editor because I have enough of this.

Specifications

Version: 2.0.11 Commit hash: 225927b9 Compiled on August 01, 2022

OS: EndeavourOS x86_64 Host: 80QR Lenovo B50-10 Kernel: 5.19.7-arch1-1 Uptime: 7 days, 1 hour, 33 mins Packages: 1348 (pacman) Shell: fish 3.5.1 Resolution: 1366x768 @ 60Hz WM: Sway (Wayland) Theme: Arc-Dark [GTK2/3] Icons: Qogir-dark [GTK2/3] Font: Noto Sans (10pt) [GTK2/3] Cursor: Adwaita Terminal: foot CPU: Intel Celeron N2840 (2) @ 2.5823GHz GPU: Intel Atom Processor Z36xxx/Z37xxx Series Graphics & Display Memory: 2.04 GiB / 7.65 GiB (26%) Disk: 119 GiB / 430 GiB (27%) Battery: 100% [Full] Locale: fr_FR.UTF-8

evanescente-ondine avatar Sep 19 '22 10:09 evanescente-ondine

Please don't open multiple duplicate issues to report a problem. I unfortunately cannot reproduce this, so I will need more information to be able to help. What sequence of actions are you taking when you experience the issue?

You could try using a default configuration with micro -config-dir /tmp and see if the issue persists. If it doesn't perhaps it is a problem with a plugin you have installed. If you really want to debug further you could try building from source and adding log.Println("...") statements (and run with micro -debug) and then check the log.txt file to see what is happening.

zyedidia avatar Sep 19 '22 16:09 zyedidia

ah, sorry I wasn't sure if I did report it or not. I don't do anything special, I just use it and close it, presumably with sigterm.

If you really want to debug further you could try building from source and adding log.Println("...") statements

Where do I add them ? I'll try to head your adivces. Since the issue did survive at least one complete OS reinstallation, it might be a plugin, but I'm very surprised no one reported the same.

evanescente-ondine avatar Sep 19 '22 19:09 evanescente-ondine

I made a plugin to open vim from micro. When we everything vim and close micro everything is fine. But if you close the terminal when vim is open without returning to micro, then the micro process continues to hang in processes. When I tested the plugin, then I opened the process manager, I saw somewhere 10+ abandoned micro processes!

I tried to find a solution here but did not find anything and then I made a simple hack:

Create a service in ~/.config/systemd/user with a name such as micro.service with the content:

[Unit]
Description=Micro Kill sleeping

[Service]
Type=simple
ExecStart=/bin/bash -c "while true; do P=$(ps u -C micro | grep Sl | grep -v Sl+ | awk '{ print $2 }'); \
[[ -n $P ]] && for p in $P; do kill -9 $p; done; sleep 30m; done"
Restart=always

[Install]
WantedBy=default.target

Set the interval sleep 30m as we want and everything is ready, now abandoned processes will be killed!

webmastak avatar Sep 22 '22 03:09 webmastak