Forum Discussion

MulgraveTester's avatar
MulgraveTester
Frequent Contributor
8 years ago

Monitoring Background Processes

How do I reference a background process that is not found in the Sys process tree?

 

My test application is a front-end GUI linked to a back-end database running as a background process. I want to test for memory leaks of the background process. I can do this fine for the GUI because it appears in the process tree but cannot get a handle on the background process.

 

sub leakTest

   'This works because myGUI is listed in the process tree

   set myGUI = sys.waitprocess("MyGUI")

   log.message ("GUI resource usage: Mem (" & myGUI.memUsage & ") CPU (" & myGUI.CPUUsage & ").")

 

   'This fails because myBEP is not listed in the process tree -

   'even though it is shown under background processes in the TaskManager

   set myBEP = sys.waitprocess("MyBackEndProcess")

   log.message ("Back End resource usage: Mem (" & myBEP.memUsage & ") CPU (" & myBEP.CPUUsage & ").")

end sub

2 Replies

  • MulgraveTester's avatar
    MulgraveTester
    Frequent Contributor

    SOLVED:

     

    sub LogResourceUsage
      strProcess = "myProcess"
      strComputer = "."
      Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

      Set colItems = objWMIService.ExecQuery("Select * From Win32_PerfFormattedData_PerfProc_Process WHERE name = '" & strProcess & "'")
      For Each objItem in colItems
          log.message objItem.Name & " CPU(" & objItem.PercentProcessorTime & ") Memory(" & round(objItem.WorkingSetPrivate/1048576, 1) & "MB)"
      Next
    end sub

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Hi MulgraveTester,

     

    Just FYI, Sys includes all processes, so Sys.WaitProcess("MyBackEndProcess") should work just fine, provided that MyBackEndProcess is the correct name.

     

    If you mean what's visible in the Object Browser, you may need to press the Show System Processes, Show All User Processes and Show Invisible Objects buttons to see non-GUI processes.

     

    Also, to access processes that run as Administrator you need to run TestComplete as Admin too.