I want cut down version pls
Hi, it's possible to boot Debian bookworm with htop reporting 3.88MiB if ram used. One suspects htop is using 1 to 1.5 MiB so would a reduced option be possible? Just reporting the ram figure overall and for the two processes, i.e. the shell and htop itself. None of the other functionality.
Coarse approximation: One process¹ (raw data) takes about 512 bytes (without referenced structures²). And that's not even accounting for OS-specific information yet.
Plus the htop binary itself is about 2MiB in size (without shared libraries). Plus a good 3MiB for just the libc, and another 512KiB for ncurses …
Put differently: the few bytes taken for process data don't matter really …
¹Actually for each thread/task ²For Linux, if I counted correctly, it's about 880 bytes, without referenced data.
Has anyone tried to slim-fit htop? Perhaps using musl? Just asking out of curiosity; I myself never had any issue with the memory usage of htop. It would be a fun idea to see how much htop could be optimized, without sacrificing too many features or functionality.
I don't see a necessity to optimize further, with >3 MiB coming from libc6, ~2 MiB from the htop binary, <2MiB by runtime data (see above) and >700KiB generously leaked by ncurses¹.
¹Data provided by running htop under heaptrack
Alternatively, can anyone tell me the command line that will return the same memory usage figure as the given by htop? I'm not great at reading code etc
Alternatively, can anyone tell me the command line that will return the same memory usage figure as the given by htop? I'm not great at reading code etc
uhhh.. free -h cat /proc/meminfo ?
uhhh.. free -h
cat /proc/meminfo ?
free -h gives a much higher value than htop
cat /proc/meminfo : which of the forty or so values is supposed to be the one that htop returns? What to grep?
See https://github.com/htop-dev/htop/blob/main/linux/LinuxMachine.c#L145-L197 if you want to re-do htop's calculation (on Linux).