-
Notifications
You must be signed in to change notification settings - Fork 29.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vscode high processor usage and memory leak #44428
Comments
@weinand looks like this is related to https://github.com/Microsoft/vscode-node-debug/blob/4d9a3a70fb776e05df218849a68cdfd2645d4ed0/src/node/extension/childProcesses.ts#L30 My experience with wmic is that it's very slow on some machines. Originally the terminal on Windows shelled out to wmic to get info on the terminal process tree periodically in order to get the "foreground" process to use in the dropdown. It worked great on my machine but when it went out I was getting reports that looks just like this that were using 100% CPU. The solution to my issue was to create this native node module https://github.com/Microsoft/vscode-windows-process-tree whose sole purpose is to get a process tree on Windows very fast, You can see it being used here. I recommend using this (and extending it if you need the args of the process). This is also probably the fastest way to get the performance information as well for |
Good to know, the problem is the wmic instances created by vscode. To fix the issue I have to kill all the WMIC.exe and WmiPrvSE.exe processes. |
The wmic processes are used by the "autoAttachChild" feature. |
@Tyriar I tried your native "windows-process-tree" module but I see the following issues:
Before I start to make my feet wet by implementing a native node module, one question: in my most complex use case (https://github.com/weinand/vscode-processes) I'm calling "wmic" twice to get the two sets of attributes I need and I then join the results. So I'm not calling wmic recursively. In all other cases I call "wmic" only once. Do you think that your native module approach is still preferable over one (or max. two) wmic executions? |
CPU and memory load is something I've looked into a little as I'm recommending this as a way for @RMacfarlane to get the Windows process information for the issue reporter. I think we should pass into the API call what properties are needed and only they will be fetched.
I'm not sure I understand what you mean by flatten the tree and building if you really need to here. Don't you need access to the whole tree to search for node processes with --inspect? Also what is windowsProcessTree(process.pid, (tree) => {
console.log(tree);
}); I would expect you to also write some
Well the issue you're seeing in task manager looks just like what I was seeing in the terminal when calling wmic recursively periodically. This is the fastest way to get the information AFAIK. |
My argument was basically: If I already get a full tree, then I need to write a recursive The different scenarios I was seeing all relied on this (hypothetical) API that calls back for individual processes: class ProcessInfo {
id: number;
parentId: number;
exeName: string;
arguments: string;
/// ...
}
listProcesses(..some platform specific query.., (pi: ProcessInfo) => {
// use pi...
}) And the implementation is based on one (or at maximum two) calls to That was the reason for my question whether your native module still has an advantage over a single (or maximal two) calls to |
@weinand the native call being used to get the information To test out for your case you could try manually require the native node module and just run that to get the native list https://github.com/Microsoft/vscode-windows-process-tree/blob/565c708369326c45d9b098b11d3a850b3871f996/lib/index.js#L6. No performance information but we should add support for fetching it in the module if that's the direction we want to go.
Yes I understand there are no recursive calls in your current solution, but you're seeing the problem I was seeing which means that wmic is taking too long to return results, at least at the rate you're polling. I expect the native option to be much faster. |
@Tyriar I think the native option will still have to do sampling to get CPU usage, which could cause issues for polling. The windows api has https://msdn.microsoft.com/en-us/library/windows/desktop/ms683223(v=vs.85).aspx and https://msdn.microsoft.com/en-us/library/windows/desktop/ms724400(v=vs.85).aspx which return the total amount of time a process/the system has used, so they would need to be checked over some interval to get the current usage. I think it's still worth investing time in the native option. |
So I think the ideal APIs are looking something like this: Listening for auto attach: // Avoid any costly querying of process data that isn't under rootPid and doesn't match the query
listProcesses(
rootPid: number,
someQuery: string,
callback: (info: ProcessInfo) => void
): void; code --status: enum QueryType {
Normal,
Performance
}
getProcessTree(
rootPid: number,
callback: (info: ProcessTreeNode) => void,
queryType: QueryType = QueryType.Normal
): void; Perhaps flags would be a good generic way to indicate what data is needed? enum ProcessData {
Cpu = 1,
Memory = 2,
Args = 4
}
getProcessTree(1, callback, ProcessData.Cpu | ProcessData.Memory | ProcessData.Args); It may also make sense to do the filtering on the native side if fetching performance data is expensive. |
EDIT: it appears my trouble is not this bug. Content left here for reference
|
@ellerymckenzie are you using But if you are using the Python extension then that might be the cause of the slowness you are seeing. Please file an issue against that extension. |
@weinand, that wasn't in my launch config so it appears you're right. As a further test I've shut down nearly all my plugins (including python) and the problem hasn't surfaced. |
@ellerymckenzie most likely your are seeing this issue: microsoft/vscode-python#1036 |
@weinand thanks that does seem to be the best candidate. |
@weinand I have two more issues to report regarding the "autoAttachChildProcesses" feature: 1 - When using the "useWSL = true" the autoAttachChildProcesses is not creating the child process(workers). I'm using Windows 10 pro developer mode with Ubuntu bash, installed Node version 9 2 - When debugging cluster using "autoAttachChildProcesses", if you set a breakpoint on the master process, but the child process are being forked, the debug list will change the reference to the child process, and you need to select the master process on the list to be able to see the breakpoint. Also if you set a breakpoint on the master process while the child process are being forked( During the initialization of the debuguer) the child process breakpoints are not going to trigger if the code if part of the initialization of the application and depend on the master process. I will make a movie ilustrating the second issue. Please let me know if you need more info. Thanks! |
|
Please note that this issue most likely originates from the However, node-debug uses |
I can't tell whether there's anything to verify in this issue |
Issue: Infinite processor usage and memory leak, keep creating sub-process infinitely ( WMI Providers)
After killing all chrome.exe and node.exe process, the vscode process still uses 90%+ and 2.5GB of processor and memory.
OBS: I'm working with nodeJS projects, using Cluster and the autoAttachChild option for the debugger, maybe it is related. I'm also using gulp tasks and webpack.
Please let me know if you need further info or any log files.
Thank you!
The text was updated successfully, but these errors were encountered: