Find Top 5 memory consuming Processes

Programming C# LINQ

PrivateMemorySize64 will return the allocated memory in Bytes for a given process. Combined with LINQ its quite easy to find the top 5 memory eaters:

using System;
using System.Linq;

namespace ConsTopFiveMemory
{
internal class Program
{
private static void Main(string[] args)
{
var query = (from p in System.Diagnostics.Process.GetProcesses()
orderby p.PrivateMemorySize64 descending
select p)
.Skip(0)
.Take(5)
.ToList();
foreach (var item in query)
{
Console.WriteLine($"Process {item.ProcessName} with PID {item.Id}" +
$" allocated {item.PrivateMemorySize64} bytes of memory.");
}
Console.ReadLine();
}
}
}