C. Jason Wilson
08/29/2022, 12:57 PMC. Jason Wilson
08/29/2022, 12:58 PMC. Jason Wilson
08/29/2022, 12:58 PMcomponent {
function terminate(){
for(thread in application.memoryUsage.threadNames){
try {
thread action="terminate" name=thread;
writeOutput('terminated #thread#<br>');
} catch (any e) {
writeOutput(e.message & '<br>');
}
}
}
function logMemory(threadName){
if(!isDefined('application.memoryUsage.threadNames')) { application.memoryUsage.threadNames = []; }
arrayPrepend(application.memoryUsage.threadNames,arguments.threadName);
if(arrayLen(application.memoryUsage.threadNames) > 3){ application.memoryUsage.threadNames = arraySlice(application.memoryUsage.threadNames, 1, 3); };
thread action="run" name=application.memoryUsage.threadNames[1] {
application.memoryUsage.mem = memUsage('MEMLOGINTERVAL');
local.fileName = ExpandPath('logs\memLog_#DateFormat(now(),'yyyy-mm-dd')#.csv');
if(!fileExists(local.fileName)) FileWrite(local.fileName, 'total,max,used,free,used_pct,timestamp' & Chr(13) & Chr(10));
local.fileObj = FileOpen(local.fileName, "append");
FileWriteLine(local.fileObj,application.memoryUsage.mem.total & ',' & application.memoryUsage.mem.max & ',' & application.memoryUsage.mem.used & ',' & application.memoryUsage.mem.free & ',' & application.memoryUsage.mem.used_pct & ',' & application.memoryUsage.mem.timestamp);
FileClose(local.fileObj);
}
sleep(1000); logMemory(threadName=CreateUUID());
thread action="join" name=ArrayToList(application.memoryUsage.threadNames);
}
// Returns total/free memory returned from java.lang.Runtime
function memUsage(systemvar){
application.memoryUsage.javaObj = {
system: createObject("java", "java.lang.System"),
runtime: createObject("java", "java.lang.Runtime").getRuntime()
};
return {
total: application.memoryUsage.javaObj.runtime.totalMemory(), // Returns the total amount of memory in the Java virtual machine.
max: application.memoryUsage.javaObj.runtime.maxMemory(), // Returns the maximum amount of memory that the Java virtual machine will attempt to use.
used: application.memoryUsage.javaObj.runtime.totalMemory() - application.memoryUsage.javaObj.runtime.freeMemory(),
free: application.memoryUsage.javaObj.runtime.freeMemory(), // Returns the amount of free memory in the Java Virtual Machine.
used_pct: round(application.memoryUsage.javaObj.runtime.maxMemory() / ( application.memoryUsage.javaObj.runtime.totalMemory() - application.memoryUsage.javaObj.runtime.freeMemory() )), // % of max memory used,
timestamp: DateFormat(now(),"yyyy-MM-dd HHmmss")
};
}sknowlton
08/29/2022, 2:43 PMC. Jason Wilson
08/29/2022, 2:51 PMC. Jason Wilson
08/29/2022, 2:52 PMbdw429s
08/29/2022, 6:25 PMbdw429s
08/29/2022, 6:25 PMbdw429s
08/29/2022, 6:25 PMbdw429s
08/29/2022, 6:26 PMbdw429s
08/29/2022, 6:27 PMsleep( 100 )
will help. A sleep will throw an interuptedException when the thread gets interrupted.bdw429s
08/29/2022, 6:27 PMsknowlton
08/29/2022, 6:45 PMAdam Cameron
@
people who are not already in the thread for help. It's great that Brad took the time to look-in, but it's not the best form to actively ping ppl without solicitation. We should leave it up to the ppl themselves if they want to pitch in. You kinda put ppl on the spot by @
-ing them.
No harm done.C. Jason Wilson
09/01/2022, 12:56 PM