!7 cmodule SaveStackTracesIfHighCPUUse > DynPrintLogAndEnabled { double period = 10.0; transient WaitForStableValue high; start { high = WaitForStableValue(period); doEvery(2.0, r check); } void check enter { if (dm_osLoading()) ret; int load = iround(dm_processCPUPercentageRelativeToAllCores()); high.set(load >= 50); if (isTrue(high!)) { time { S traces = renderAllThreadsWithStackTraces(); logQuotedWithDate(javaxDataDir("high-cpu-stack-traces.txt"), traces); } done_always("CPU load: " + load + "%, saving stack trace"); high.set(false); // wait another 10 seconds } } }