Hi
I wonder if someone can point me in the right direction here.
I'm testing an application which has a memory leak, at periods throughout the night I want to open the task manager and record the process details for this application. I've written a script which highlights the process and uses 'GetTextInRect' to capture the process details into a text file. This works sometimes however what I find is that my applications process doesn't always appear in the same place.
I've also used the Image recognition feature to do the same thing but this seems a bit over kill for this.
I haven't written any code before and I'm still just learning with this particular tool so any answers please keep them simple.
I've attached my script.
//Gets the list of processes for system status.exe from task manager and saves to a text file
SRT>Task Manager
Let>RP_WAIT=2
Run>taskmgr.exe
WaitWindowOpen>Windows Task Manager
WindowAction>1,Windows Task Manager
Wait>1.2
Send>system status.exe
SetFocus>Windows Task Manager
Wait>1
GetTextInRect>24,110,840,125,Taskmanager
TimeStamp>C:\Documents and Settings\Administrator\Desktop\Script Logging\Target Keypad Stress Test.txt,%Taskmanager%
Wait>0.5
CloseWindow>Windows Task Manager
End>Task Manager
Thanks for any help
Logging a process from the task manager
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Well, I would scrap that method entirely, as you can get memory usage of a process from the command line using the tasklist command.
So this script uses that to get the memory usage of a given process:
Adapt to suit your requirements/config.
So this script uses that to get the memory usage of a given process:
Code: Select all
//get memory usage of a process:
Let>process=outlook.exe
Let>RP_WAIT=1
Let>RP_WINDOWMODE=0
Run>cmd.exe /c tasklist /FI "IMAGENAME eq %process%" >> "%TEMP_DIR%memusage.txt"
ReadFile>%TEMP_DIR%\memusage.txt,theInfo
DeleteFile>%TEMP_DIR%\memusage.txt
//the last value contains the memory usage
Let>pattern=\s[\d,]+\sK$
RegEx>pattern,theInfo,0,matches,nm,0
Let>mem_usage=matches_1
//so we could now log mem_usage to file or whatever you want to do with it
MessageModal>Memory Usage of %process%: %mem_usage%
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Or you could do:
Although I think that's a slightly different metric. Values available to you can be seen here:
http://msdn.microsoft.com/en-us/library ... s.85).aspx
Code: Select all
VBSTART
Function GetProcessMemoryUsage(procname)
Set objWMI = GetObject("winmgmts:\\.\root\cimv2")
Set colObjects = objWMI.ExecQuery("Select * From Win32_Process")
For Each Item in colObjects
If Item.Name=procname Then
GetProcessMemoryUsage = Item.WorkingSetSize
Exit For
End if
Next
End Function
VBEND
VBEVal>GetProcessMemoryUsage("OUTLOOK.EXE"),size
MessageModal>size
http://msdn.microsoft.com/en-us/library ... s.85).aspx
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Thanks for the prompt reply Marcus.
As yet I don't fully understand the middle section '//the last value contains the memory usage' but it works great retrieving the memory usage.
I've now looked under the tasklist but can't see if there is a way of recalling other parameters that are listed in the Task manager such as 'VM Size' I'm interested in logging this aswell as the Memory usage?
Thanks
As yet I don't fully understand the middle section '//the last value contains the memory usage' but it works great retrieving the memory usage.
I've now looked under the tasklist but can't see if there is a way of recalling other parameters that are listed in the Task manager such as 'VM Size' I'm interested in logging this aswell as the Memory usage?
Thanks
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Yes, in exactly the same way.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?