Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

VB.Net: Getting memoryusage of one process

From Wiki

Revision as of 06:59, 9 June 2008 by chrissie1 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
  1. Public Shared Function GetMemoryUsage(ByVal ProcessName As String) As String
  2.             Dim _Process As Process = Nothing
  3.             Dim _Return As String = ""
  4.             For Each _Process In Process.GetProcessesByName(ProcessName)
  5.                 If _Process.ToString.Remove(0, 27).ToLower = "(" & ProcessName.ToLower & ")" Then
  6.                     _Return = (_Process.WorkingSet64 / 1024).ToString("0,000") & " K"
  7.                 End If
  8.             Next
  9.             If Not _Process Is Nothing Then
  10.                 _Process.Dispose()
  11.                 _Process = Nothing
  12.             End If
  13.             Return _Return
  14.         End Function

You will have to pass it the name of the process for which you want to have the memoryusage. It is the same name as shown by the task manager in the tab Processes in the Image name column.

381 Rating: 2.4/5 (31 votes cast)