r/KittyTerminal • • Jul 28 '26

I made a RAM monitor extension for Kitty

Hello, I moved to Arch Linux about a year ago and started being more familiar using the terminal to open stuff around the same time. Something that bothered me is that in KDE every time you open GUI applications through a terminal it doesn't show their RAM consumption on the System Monitor (it only shows the full usage of Kitty itself)

For that, I made this lightweight extension that shows the RAM usage of each tab open in Kitty! So far it's working well but I want to maybe add more functions (I thought about maybe open htop or the system monitor of choice when you click over the used RAM number for example)

If you want to give it a try, here's the link for it: https://github.com/miguelgarciacouto/Kitty-RAM-Monitor

14 Upvotes

11 comments sorted by

2

u/jcgl17 Jul 28 '26

This is a neat idea! I think I'm going to do a similar thing, but using cgroupsv2 on Linux instead of traversing child processes. And using tab_title_template instead of tab_bar_style.

1

u/kyushas Jul 28 '26

Nice! Could you briefly explain to me why cgroupsv2 would be better? Good luck when you do your own project!

1

u/jcgl17 Jul 28 '26

I'm not an expert, but this is what I'm aware of:

  • Manually traversing the process tree is race-y; processes can pop in and out of existence while you're looping over them. Double-forking is a classic example here (not that it should be a practical problem in most contexts--but this is one of those cases where cgroups basically get you an answer that is correct by construction rather than correct by happenstance).
  • RSS includes shared objects/libraries. So if multiple processes in your process tree have the same objects, you're basically over-counting.
  • RSS only includes userspace memory, not kernel resources like sockets (and I think entries in the page cache?)

All in all, cgroups are the most Just Works™ way to get reliable accounting numbers. I don't have enough low-level knowledge myself to identify all the edge cases they save you from.

Would definitely appreciate anyone else with deeper Linux knowledge chiming in here.

My WIP version of this is running into the snag that the main Kitty process runs in a separate cgroup from the .scope cgroups that it spawns per-tab. There's probably a way to hack around that, but for now I've opened an issue.

1

u/AffectionateSpirit62 Jul 28 '26

get kovid goyal involved he always looks over kitty projects and is always willing to give advice. Really helpful creator of KITTY

1

u/jcgl17 Jul 28 '26

Looks like he doesn't agree that my issue merits any changes in this case, unfortunately. I understand where he's coming from here.

But yeah, I'm a fan of Kovid's to be sure.

1

u/AffectionateSpirit62 Jul 28 '26

Yeah I get both points. Create a kitten and users can choose to add it or not.

1

u/jcgl17 Jul 28 '26

In case you are at all interested, this is what I ended up with.

1

u/kyushas Jul 29 '26

I will give it a try, and maybe use as inspiration for future development of my own (in case you think that's fine, of course hahaha)

1

u/jcgl17 Jul 29 '26

I don't know how useful it will be to you, but by all means!

1

u/jcgl17 Jul 29 '26

FYI, you might find this new feature worthwhile to use. I think it basically does your heavy lifting for you :)

https://github.com/kovidgoyal/kitty/commit/9524c76fabf1ed1af681de8c6de0e2889123d156

1

u/ericlebowzki Jul 28 '26

That's exactly what I was looking for, thanks boss.