Forum Discussion
tristaanogre
Esteemed Contributor
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);
}
}
GGuezet
7 years agoContributor
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.
Related Content
- 11 months ago
Recent Discussions
- 12 hours ago
- 2 days ago