xmonad / xmonad-contrib

Contributed modules for xmonad
https://xmonad.org
BSD 3-Clause "New" or "Revised" License
579 stars 271 forks source link

CPU usage is higer than once (Could it may be a memory leak?) #849

Closed thealio closed 6 months ago

thealio commented 6 months ago

Hi I've noticed that the CPU usage of my xmonad session seems higer than once I noticed this opening my leftwm session recently. I have the same configuration on both , same startups etc. Opening only htop on alacritty , (plus of course the starups , and polybar on both) it seems that my xmonad session uses 10-11% of CPU , while leftwm only 0,7-1%

I'd like to know if there is sorta like of memory leak on the latest releases, or if you guys had noticed something similar, and if possible memory leak were recently investigated , and if not I require a check about that.

I'm on Arch , I have xmonad + xmonad-contrib + xmonad -extras installed

slotThe commented 6 months ago

I haven't noticed any changes personally, but then I don't really have a habit of keeping xmonad running for more than a few days at a time (e.g., my current uptime is 2 days and some hours, while CPU usage (and, more important for this, memory usage) sits comfortably at 0% (resp. 0.2%).

If you think there is a problem, profiling XMonad as was done in https://github.com/xmonad/xmonad-contrib/pull/653 should certainly reveal it.

thealio commented 6 months ago

I haven't noticed any changes personally, but then I don't really have a habit of keeping xmonad running for more than a few days at a time (e.g., my current uptime is 2 days and some hours, while CPU usage (and, more important for this, memory usage) sits comfortably at 0% (resp. 0.2%).

If you think there is a problem, profiling XMonad as was done in #653 should certainly reveal it.

Hi, I figure out what caused the higher memory usage

I used xmonad + polybar.


xmonad $ ewmh $ docks $ ewmhFullscreen $ pagerHints $ myDefaults
-- $ pagerHints is required for print the current layout in xmonad ( xprop -root _XMONAD_CURRENT_LAYOUT | awk '{print $NF}' | tr -d "\"" )

On polybar, I wrote a custum module that shows the current layout on the bar . The module is the following:

[module/xmonad-layout]
type = custom/script
format-prefix = " "
format-foreground = ${colors.color07}
format-background = ${colors.color00}
exec = xprop -root _XMONAD_CURRENT_LAYOUT | awk '{print $NF}' | tr -d "\""
tail = true

It extract the layout with xprop -root _XMONAD_CURRENT_LAYOUT | awk '{print $NF}' | tr -d "\""

It seems that this caused the unusual high CPU consumption , I don't know exactly why this happens.

geekosaur commented 6 months ago

How often is it running? If it's spawning it for every update, it could be running quite often and spawning shells constantly.

thealio commented 6 months ago

How often is it running? If it's spawning it for every update, it could be running quite often and spawning shells constantly.

every time switch layout it runs for sure, I don't know if actually it never-ending runs in the background. I don't know if there is a way to stop after every run

slotThe commented 6 months ago

Seems very much like something you should ask the polybar people

thealio commented 6 months ago

Seems very much like something you should ask the polybar people

Thank you for your support, I've already reported to the polybar team.

However , I'll report the code I've modify that fix the issue, for completeness

[module/xmonad-layout]
type = custom/script
format-prefix = " "
format-foreground = ${colors.color07}
format-background = ${colors.color00}
exec = xprop -root _XMONAD_CURRENT_LAYOUT | awk '{print $NF}' | tr -d "\""
; tail shoud be commented or turned off, to avoid CPU high usage
; tail = true
 interval = 1