Forum Discussion

cshukusky's avatar
11 years ago

Tracking Memory Usage

I have a need to be able to record the memory usage of a tested application.

I looked through the help files for TestComplete and found the MemUsage property for processes.

The problem is the MemUsage property gives me the working set, but I am more concerned with the private working set.

Is there a way for me to get the private part of the working set in TestComplete?

6 Replies

  • murugans1011's avatar
    Regular Contributor
    I m not sure this can be done with TC. To keep track of memory usage in your application you need a separate tool called AQtime
  • HKosova's avatar
    SmartBear Alumni (Retired)

    Hi Chris,

    You can get the private working set using WMI classes, namely, Win32_PerfRawData_PerfProc_Process.WorkingSetPrivate.

    function TestGetPrivateWorkingSet()


    Log.Message("Notepad's private working set: " + GetPrivateWorkingSet("NOTEPAD") + " bytes");


    // Returns the private working set, in bytes, of the specified process.

    // Parameter:

    // ProcessName - the process name without the extension (case-insensitive). E.g. "notepad".

    function GetPrivateWorkingSet(ProcessName)


      var oWMI = GetObject("winmgmts:");

      var oPerfData = oWMI.Get("Win32_PerfRawData_PerfProc_Process.Name='" + ProcessName + "'");

      return oPerfData.WorkingSetPrivate;


    If you need to query memory several times throughout your test, you can use the following code with a WMI refresher. This should work faster than calling GetObject("winmgmts:") multiple times:

    function Test()



      // Do something


      // Do something else



    var oCounter;

    function InitCounters(ProcessName)


      var oRefresher = new ActiveXObject("WbemScripting.SWbemRefresher");

      var oWMI = GetObject("winmgmts:");

      oCounter = oRefresher.Add(oWMI, "Win32_PerfRawData_PerfProc_Process.Name='" + ProcessName + "'");


    function GetPrivateWorkingSet()



      return oCounter.Object.WorkingSetPrivate;


  • Thanks for the reply, but showing the memory for every action the test does in the test log, while useful, is not quite what I was looking for.

    I am looking to grab the memory for a few particular steps during a test run, and be able to record that in an excel file for example, and then write a script to manipulate that data into a report for managers to look at.

    The managers would not be too keen on looking through the memory for every single action the test does and I did not notice any way to manipulate the performance counter in a script.

    If there is a way to do that, then this is a possibility, but I am certainly not going to go through the results manually and pull out the few pieces the managers want to see.

    Optimally, I was hoping for another property like memusage that just showed the private memory usage, which I could record to excel during the test run only when I want to.
  • Thanks for the reply, but understandably, I was hoping to not have to spend money on another tool.  I am wondering if I cannot suggest a feature enhancement for TestComplete to have a private memory property on the process.  Though, if they already have another tool for memory profiling, I guess it probably wouldn't happen.
  • Helen,

    Thank you.

    I gave your suggestion a try and it looks like I will be able to do exactly what I had hoped to.

    - Chris