20

I am running a Debian flavor of Linux, and I use htop to keep track of memory usage, since it is more detailed than top. I can't seem to get it to sort by memory and display process trees at the same time. Is there a way to do this with htop or an alternative?

bright-star
  • 1,569
  • 2
  • 14
  • 28

4 Answers4

9

A 2019 update on this 2014 question that ranked highly when searching for this topic is that htop has this built in now, and in the current version 2.2.0, simply pressing t in the default view generates a process hierarchy.

Rich L
  • 191
  • 1
  • 3
  • 2
    I don't think this answers his question since pressing `t` only changes view to tree but keeps not allowing you to sort at the same time. I'm using version 2.0.2. – Sidney de Moraes May 20 '20 at 12:27
8

Looks like Glances should have what you need:

glances --tree

And then sort using commands m,t, i etc. Full command reference

ComputerDruid
  • 213
  • 1
  • 6
pkk
  • 129
  • 1
  • 3
1

Not with htop (and probably with any other alternative) as both views are mutually exclusive: either you list processes sorted by memory, or respect the PPID/PID tree view. You can have both at the same time.

dawud
  • 1,450
  • 12
  • 18
  • 17
    Sure, but since there is a hierarchical relationship there, you could aggregate the memory or CPU usage of the tree and then sort on that. – bright-star May 03 '14 at 03:08
  • 1
    On one of my server htop 1.0.1 does indeed lists the processes and their threads in tree view *and* sorted by CPU% (based on the process cpu%). On my other server, there is htop 1.0.2 and setting `sort by CPU%` automatically clears the tree view. – karatedog Jun 21 '16 at 17:20
  • 2
    To clarify what @TrevorAlexander said, siblings in the tree could be sorted against one another without breaking the tree display – Aaron J Lang Sep 02 '16 at 10:12
0

In htop version 3 (I believe, 3.0.3 to be exact) you can sort by other columns than pid even in tree mode.

See the changelog.

It's not perfect, because it doesn't aggregate memory from sub processes, but it's a nice feature nonetheless.

Dario Seidl
  • 3,735
  • 1
  • 20
  • 22