Skip to content

Commit

Permalink
[fix] Fix 100% CPU usage on Windows
Browse files Browse the repository at this point in the history
Fix the problem that systeminformation keeps launching new powershells on
Windows platform, causing CPU usage to rise to 100%.
More details: sebhildebrandt/systeminformation#626
  • Loading branch information
zincnode committed Jun 18, 2023
1 parent 49e9802 commit df19da7
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import * as vscode from 'vscode';
import systeminfo = require('systeminformation');
import * as os from 'os';

export const platform = os.platform();
export const isWin32 = platform === 'win32';

export function systeminfoInit() {
if (isWin32) {
systeminfo.powerShellStart();
}
}

let cpuItem: vscode.StatusBarItem;
let memItem: vscode.StatusBarItem;
Expand All @@ -13,12 +23,17 @@ export function activate({ subscriptions }: vscode.ExtensionContext) {
dockerItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, -130);
subscriptions.push(cpuItem, memItem, uptimeItem, dockerItem);

setInterval(getCPUUsage, 500);
setInterval(getMemoryUsage, 500);
setInterval(getUptime, 500);
setInterval(getDockerUsage, 500);
setInterval(getCPUInfo, 500);
setInterval(getDockerInfo, 500);
setInterval(allUpdate, 500);
}

async function allUpdate(): Promise<void>{
systeminfoInit();
getCPUUsage();
getMemoryUsage();
getUptime();
getDockerUsage();
getCPUInfo();
getDockerInfo();
}


Expand Down

0 comments on commit df19da7

Please sign in to comment.