Skip to content

Bug: [Excessive RAM usage reported by tmux_ram_info.sh plugin] #321

Open
@druxorey

Description

@druxorey

Bug: [Excessive RAM usage reported by tmux_ram_info.sh plugin]

Describe the bug

The tmux_ram_info.sh plugin shows an excessive RAM usage when nvim is open that does not match the actual usage.

image
Which does not match the ram that my system is using.

image

To Reproduce

Steps to reproduce the behavior:

  1. Go to 'tmux'
  2. Run the tmux_ram_info.sh script
  3. Observe the reported RAM usage

Note: The plugin seems to work fine, but when using nvim with lazyvim, it does not count the processes correctly.

Expected behavior

The script should report accurate RAM usage.

System

  • OS: Arch Linux
  • Tmux Version: Latest

Possible solution

I found a possible solution but I would like to discuss it before making a PR. The original code on line 74 does this:

total_mem_kb="$(ps -o rss= -p "$pids" | paste -sd+ - | bc)"

So I changed it to this:

total_mem_kb="$(ps -o rss= -p "$pids" | awk '!seen[$0]++' | paste -sd+ | bc)"

Which shows me a better representation:
image

NOTE: I adjusted the rounding to better display the values, but in my solution, the rounding will remain the same.

When I run the command pstree -p "$pid" with the tmux PID, it shows a tree with multiple processes having different PIDs:

image

And when extracting their sizes in bytes using ps -o rss= -p "$pids" it give us this result:

 8968
10628
47736
 9632
69208
151140
151140
151140
151140
151140
151140
151140
151140
151140
151140
151140
221548
221548
221548
221548
221548
221548
221548
221548
221548
221548
221548
69208
69208
69208
69208
47736
47736
47736
47736
47736
47736
47736
47736
47736
11356
10268
 9960

However, it appears that we should not sum all of them because some PIDs are repeated. My solution was to sum only the unique values to total_mem_kb, but I am not sure if it's the best solution for this bug.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions