Ask a Question

Takes a long time to get MemUsage info for 1 of 2 processes

sak
Occasional Contributor

Takes a long time to get MemUsage info for 1 of 2 processes

I have a system that is running a number of processes, and would like to record the memory usage of two processes over a brief period of time.  I have used the following code to write the information to a file:



  for (i = 0; i < 10; i++)

  {

    text = aqString.Format("% 3i:\t%i\t%i\t\r\n", i, Sys.Process(proc1).MemUsage, Sys.Process(proc2).MemUsage);

    //text = aqString.Format("% 3i:\t%i\t\r\n", i, Sys.Process(proc1).MemUsage);

    //text = aqString.Format("% 3i:\t%i\t\r\n", i, Sys.Process(proc2).MemUsage);

    aqFile.WriteToTextFile(sPath, text, aqFile.ctUTF8);

    Delay(1000);

  }  



Whenever I use "Sys.Process(proc2).MemUsage", there is a delay of about 10 seconds and a message "Waiting for proc2" appears in the upper right corner of the screen (I guess that is the status of the executing script); whenever I use "Sys.Process(proc1).MemUsage" the action seems to be immediate.  I can see in Task Manager that both processes are running.  When I use either line that just writes memory usage for a single process, I only see the ~10 second delay for proc2.  I'm guessing that the code above is okay since it works for one process, so I'm wondering what could be different about proc2 that incurs this long delay?  Both process are using in the range of 2% to 7% of the processor, which is running at between 15% and 22%.  Any ideas or suggestions would be greatly appreciated!



(The numbers that I see for memory usage for both processes are consistent with what Task Manager is showing, so I do seem to be getting the correct data...)
9 REPLIES 9
sak
Occasional Contributor

RE: Takes a long time to get MemUsage info for 1 of 2 processes

I should have noted that I am running the script under TestExecute 8.0
irina_lukina
Super Contributor

RE: Takes a long time to get MemUsage info for 1 of 2 processes

Hi Steve,


I failed to reproduce the behavior you described. There were no unexpected delays when I ran the test for the two processes. I think, this may be specific to Proc2 or to your project. To help us investigate the problem, please follow the instructions below:

1. Provide us with the entire code of your test.

2. Describe the Proc2 process you are trying to explore.



If you don't want to share your code on the forum, please contact our Support Team directly via the Contact Support form.


Thanks.

I’m not a member of the SmartBear Support Team, I’m just helping users in this community. Any views or opinions expressed do not necessarily represent those of SmartBear Software.
sak
Occasional Contributor

RE: Takes a long time to get MemUsage info for 1 of 2 processes

Hi Irina,



Thanks for the reply!  proc1 is an OPC Client Adapter, and proc2 is an OPC Server Adapter.  Both are registered as Windows services.  If this info is not helpful, I will contact SmartBear Software Support.



I suspect that the problem is related to something in proc2, but can't imagine what the process could be doing that would make the memory usage information unavailable from Windows.



Steve
irina_lukina
Super Contributor

RE: Takes a long time to get MemUsage info for 1 of 2 processes

Hi Steve,


It's difficult to say what is wrong with the process.


So, I recommend that you contact our Support Team and send them the following information:

1. Your project.

2. Information about your operating system, installed programs, and so on.

3. Please try running your project on another machine (physical or virtual) and inform the Support Team about the results.


Thanks.

I’m not a member of the SmartBear Support Team, I’m just helping users in this community. Any views or opinions expressed do not necessarily represent those of SmartBear Software.
sak
Occasional Contributor

RE: Takes a long time to get MemUsage info for 1 of 2 processes

Hi Irina,



I have been given a higher priority task, so this issue is temporarily on "hold".  😞



For what it is worth, a coworker pointed out to me that the service "proc1" is owned by" SYSTEM" (running Windows 2003, SP2) but the service "proc2" has been configured to "Log On" as another user so it can be remotely started by DCOM.  The belief is that this problem has been seen before and that it may be related to a permissions issue.



I will probably pursue that idea once I'm back on this project.



Thank you.



Steve
irina_lukina
Super Contributor

RE: Takes a long time to get MemUsage info for 1 of 2 processes

Hi Steve,


When you return to this task, please contact our Support Team and send them the information I mentioned in my previous post.


Thanks.

I’m not a member of the SmartBear Support Team, I’m just helping users in this community. Any views or opinions expressed do not necessarily represent those of SmartBear Software.
GGuezet
Contributor

Re: Takes a long time to get MemUsage info for 1 of 2 processes

I know this is an old thread, but I'm experiencing the exact same issue when working with processes.

I'm using testcomplete 11, lastest update.

The function .MemUsage used to work very well, and for some reason, without any update, and not even closing the TestComplete window, it started to wait 15s for each process.

 

Testcomplete will wait as long as the "auto-wait timeout" setting you've specified into your project settings.

 

The only workaround I've managed to find is to use "Options.Run.Timeout = 100" before checking processes, and to set it back to default after checking processes.

 

I've seen the same problem with Sys.Process(ProcessName).Exists, and "solved" it the same way...

tristaanogre
Community Hero

Re: Takes a long time to get MemUsage info for 1 of 2 processes

Generally speaking, if you want to get MemUsage of a process and you're not certain the process exists before you do so... or, for that matter, you want to check to see if the process exists before you do soemthing with it, the Best Practice method is to use the WaitProcess method.

 

So... let's say i want to get MemUsage of app1.  HEre's how I'd write it in JavaScript

 

function checkMemUsage(processName){
    var processObject;
    processObject = Sys.WaitProcess(processName, 20000); //waits for the process up to 20 seconds
    if (!processObject.Exists){
        Log.Error('Process ' + processName + ' is not memory resident');
return -1; } else { return processObject.MemUsage; } }


function test(){
var appMemoryUsage;
appMemoryUsage = checkMemUsage('app1');
if (appMemoryUsage == -1){
Log.Error('Unable to retrieve memory usage for app1');
}
else{
Log.Message('Memory usage for app 1: ' + appMemoryUsage);
}

}

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
GGuezet
Contributor

Re: Takes a long time to get MemUsage info for 1 of 2 processes

In my case I know that the process exists, because i've done an if Sys.WaitProcess("My_Process",10000).Exists then before, and it still "wait for process" on the .MemUsage line.

cancel
Showing results for 
Search instead for 
Did you mean: