Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List all processes and their current memory & CPU consumption?

How can I get a list of all processes in C# and then for each process current memory and CPU consumption?

Sample code is highly appreciated.

like image 378
Alex Avatar asked Aug 08 '09 06:08

Alex


People also ask

How do I list all processes in Linux?

To list processes in Linux, use one of the three commands: ps, top or htop. Ps command provides static snapshot of all processes, while top and htop sorts by CPU usage.

How do I find the top 10 processes in Linux?

Use ps Command to Find Top Processes by Memory and CPU Usage ps is a Linux command-line utility with many options that helps you to display output in different formats. You can use the ps command with –sort argument to sort the output by memory and CPU usage.

How do I check my RAM processes?

Or, right-click the Taskbar and select Task Manager. Select the Performance tab and click Memory in the left panel. The Memory window lets you see your current RAM usage, check RAM speed, and view other memory hardware specifications. Open the Processes tab to see which tasks are consuming the most RAM.


1 Answers

The Process class has a GetProcesses method that will let you enumerate the running processes and list a bunch of stats like memory usage and CPU time. Look at the documentation under properties for the stats.

Memory usage is a complex matter. There is really no single number, that describe the usage. Please see Russinovich's excellent series on the matter. The first installment is here: http://blogs.technet.com/markrussinovich/archive/2008/07/21/3092070.aspx

like image 120
Brian Rasmussen Avatar answered Sep 30 '22 19:09

Brian Rasmussen