Computer Programming tricks Useful

Top 5 Memory Consuming Processes Running in Your PC

We do a lot of things with our PC like reading News, Opening Mails, Playing Videos, Making Presentations, Running Programs and a lot more. But we never wait for a process to complete to start another process. We start all of them simultaneously. And sometimes it creates problem, our computer may go very slow, it may become unresponsive, sometimes it also hangs down. So in such situations it is very important to track the physical memories being utilized by different processes. If any process is taking a lot of physical memories then  you can even stop them. Today I will tell you how to track the physical memories being utilized by different processes at a particular time very quickly.

What is the problem with Task Manager ?

You can simply check this by going to Task Manager and Resource Monitor. But when your computer goes slow, even the task manager takes a lot of time to load and more over, it also takes some physical memory as it shows a lot of real time CPU graphs. So you may not want to open the task manager during this critical time. So I am going to tell you what to do in such situations.

How to do this?

Just copy and paste the following code in a notepad and save it in .vbs extenision. For example I will suggest you to save it as task.vbs

n = 5
Set objWMI = GetObject("winmgmts:\.rootcimv2")
Set colObjects = objWMI.ExecQuery("Select * From Win32_Process")
Dim usage1(9999)
Dim name1(9999)
Dim size
Dim finalMes
For Each Item In colObjects
size = size + 1
usage1(size) = Item.WorkingSetSize
name1(size) = Item.name
Next

For i = 1 To size
For j = i + 1 To size
If (Int(usage1(i)) < Int(usage1(j))) Then
temp1 = usage1(j)
usage1(j) = usage1(i)
usage1(i) = temp1
temp2 = name1(j)
name1(j) = name1(i)
name1(i) = temp2
End If
Next
Next

finalMes = "Top " + CStr(n) + " Memory Consuming Processes" + vbCrLf + vbCrLf
For i = 1 To n
finalMes = finalMes + name1(i) + " ---> " + CStr(usage1(i) / 1024) + " KB" + vbCrLf
Next

MsgBox finalMes, vbOKOnly, "On " + CStr(Date) + " At " + CStr(Time)

It will quickly show you the top 5 processes which are consuming most of your physical memory.No need to open any Task Manager or Resource monitor.

Can I see top 10 processes in the list ?

Yes, definitely you can. Just look in to the VB code you can find n=5 in the first line. Just change it to n=10 to see top 10 processes in the list. As simple as it is.


Leave a Reply

Your email address will not be published. Required fields are marked *