-
Notifications
You must be signed in to change notification settings - Fork 499
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
PSES using large amounts of memory (> 1GB) #1552
Comments
Possibly related to #1464. If you are able to diagnose or profile this in any more detail we are grateful for any data you can provide. VSCode/Electron already loves machine resources, but I'd like to drive our footprint down as much as possible. One thing we've learned is that every machine profile is different and trying to reproduce a performance issue between machines is a challenge. The PowerShell process you're looking at is PowerShell Editor Services, which is what does all the heavy lifting for the extension. So it makes sense that it has a relatively large footprint (for example, it generates a new PowerShell AST every time you press a key), but I am currently working on reducing that as much as possible. |
Thanks for the reply. That issue might be related, however my cpu usage isn't an issue. And playing around with it on a different computer it does gradually increase in size but on the one I reported from there is unresponsiveness more often. |
Yes disabling features isn't a long term solution. We have been working on performance in general. The CPU/memory usage is related since memory/resource-intensive operations increase garbage collection pressure. In the coming release I'm hoping you'll experience some improvements in both. Another thing to bear in mind is that memory allocated to an application is not necessarily in use. The OS will try to allocate based on need, and it's really memory pressure/thrashing that is a worry. But as I say, if you can provide any more information on what inside that PowerShell process is asking for all that memory, like with a usage or profile trace, that would be very helpful. |
I disabled scriptanalyzer and things sped up significantly. So that perhaps narrows it down a bit. Maybe I just have too many errors in my code...I hope not, I really don't have that many. |
Ah, yeah ScriptAnalyzer is pretty much next on the list of things for us to work on. It's a bit of a resource hog unfortunately and we're trying to find ways to isolate it, but ultimately we depend on work being done in PSScriptAnalyzer itself (in https://github.com/PowerShell/PSScriptAnalyzer). So theoretically the best way to get trace/profile data is with Visual Studio or Windows Performance Toolkit. But unless you've used them before or something similar, they're fairly unintuitive. Instead, it's probably worth:
Sorry that's not more helpful. Ideally we'd have a simple profiling tool to plug & play with, but I don't think we're really close to that yet. WPT does do a plug/play dump though, so if you want to try using that, you can just send us the dump and we can analyse it |
I am familiar with the other tools in the windows ADK so I'll see what I can do with the windows performance toolkit. |
One thing I'm trying (and yes I see this is 5+ years later) is this: CTRL+SHIFT+P (command palette opens) What's kind of cool is you can click the gear wheel beside "PowerShell: Restart Session" and give it a key binding. I went with CTRL+ALT+P. To test, I first to the command" PowerShell: Show Extension Terminal" so I can actually see it in the panel, then I do my CTRL+ALT+P to see it disappear again (since I check that box to start it in the background, which is a default I believe). I have found on my 16GB RAM laptop, with present day current version VSCode, the pwsh.exe (which the Command Line in Task Manager shows as the one with Import-Module ...PowerShellEditorServices.psd1) will have consumed 10+GB of RAM. This is while I use 3 other pwsh.exe instances in the same VSCode panel, each connected to a different Exchange environment (EXO, 2x on-premises). Those pwsh.exe's don't have the high memory consumption typically, but the extension's pwsh.exe definitely does. It's fine though now that I know how to recycle it per se. |
@JeremyTBradshaw when we saw reports of high memory usage it's almost universally caused by having a workspace with many PowerShell files, as this by default causes the extension to run PSScriptAnalyzer and symbol finding on all the files. To alleviate this issue we added the setting |
Thanks for that, very much! Makes perfect sense. I was searching around for existing issues but hadn't come across that yet. Will give it a go, leaving the restart trick as last resort. |
This issue has been labeled as resolved and has not had any activity for one or more days. It has been closed for housekeeping purposes. |
Issue Description
I've noticed recently that my vscode is often using nearly 2 GB of Ram, which seems a bit high for a text editor, but I figured it was just too many editors open. Today I looked a little deeper and found that it's mostly from one attached powershell process.
The command line of the process looks like this
This script seems to start when I open vscode and doesn't seem to close. There is various hanging on powershell extension functions while I'm editing. From parameter/function auto complete to help comment block creation.
I'm thinking there may be something causing it to hang or use more RAM then expected.
Environment Information
Visual Studio Code
PowerShell Information
Visual Studio Code Extensions
Visual Studio Code Extensions(Click to Expand)
The text was updated successfully, but these errors were encountered: