How to Diagnose System Usage with a LINQ Query


How to Diagnose System using LINQ Query

This query determines the top 5 memory-using applications currently loaded.

 Dim pList = From p In System.Diagnostics.Process.GetProcesses() _
                Select ProcessName = p.ProcessName, _
                Size = (Format(p.WorkingSet64 / 1000, "#,##0") & " KB"), _
                Size64 = p.WorkingSet64 _
                Order By Size64 Take 5

    Console.WriteLine("These 5 processes are using the most memory:")

    For Each p In pList
        Console.WriteLine(p.ProcessName & " - " & p.Size)
    Next

Result:

These 5 processes are using the most memory:
Idle - 16 KB
System - 217 KB
smss - 381 KB
lsass - 934 KB
vpcmap - 958 KB

 


Similar Articles