-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Running notebook cells uses all available memory #146768
Comments
Thanks for the issue. Can you include the contents of the output 'Jupyter' tab. Additionally can you tell us your settings? This setting here might cause this problem: "jupyter.generateSVGPlots": true |
@rchiodo I checked the SVG plots setting, it’s not on. The Jupyter output tab doesn’t show much when this happens. Just the "Adding hash for..." message when the cell is executed, and then it hangs. |
And the memory usage of the kernel is really large? The full output of the jupyter tab may indicate something before you started running the cell. The output doesn't have your code in it, just your user name folder, so it shouldn't include any of your IP in it. |
@rchiodo full output of Jupyter tab is below. Here I executed two cells which set up some necessary stuff, and they ran fine. The output was captured before running the third one, which caused a hang. I see that I'm in some Jupyter 'experiment groups', maybe I should try disabling the experiments?
|
Unfortunately all that tells me is that it worked and that you're running code through the interactive window. I thought it might be related to jedi (what jupyter uses for auto completion) in the jupyter process but your extension version is new enough that we automatically disable jedi now. Hmm, I think we'd need to generate a custom jupyter extension to debug this. Or if you can give us a repro that you can share then we could investigate here. My only guess is that our startup code is somehow affecting your kernel. That should be the only difference between running our code and running this in jupyter. |
Does the problem repro if you run the code inside of a notebook instead of the interactive window? It might be our debug hook that's causing the problem (only used for interactive window): |
Debug hook looks like this: Essentially it creates a SHA1 hash of your code so we can name the cell for debugging. Naming the cell sets an environment variable. I don't think this could cause a problem, but maybe the sha1 algorithm is really slow? And we did change this a couple of months ago (corresponds to when you said the problem started happening). |
@rchiodo I just ran the code inside of a VS Code notebook, and yes it still does crash. I'm trying to come up with a minimal repro. It's not really a matter of code-related IP to be honest. It's more that the code reads some 3D imaging data using external libraries. Setting up the whole environment and test files on another system would be somewhat involved. |
Hmm, just noticed that you said VS code crashed, not the kernel. This might be a memory leak in VS code core that was just fixed yesterday. Would you be able to try the insiders build of VS code to see it works there? |
Thanks for the suggestion @rchiodo. I updated Insiders to the latest version and ran the code there. Unfortunately the crash still persists. However I did make some progress. My code generates plenty of debug messages via the |
Confirmed that I can crash VS Code by just running the following cell:
The first time it hung after printing 1438 warnings. The second time it hung without printing anything at all. However I can't seem to crash it by e.g. printing a lot of numbers using |
This is the classic issue of the jupyter extension concatenating all streaming output and calling And we can't use 'append' just because the jupyter extension has to process possible terminal ansi codes, is that right? https://github.com/microsoft/vscode-jupyter/blob/d4aa4ea7855a8c148e91f10805da2a8402466694/src/kernels/execution/cellExecutionMessageHandler.ts#L849 There has to be a better way to do this |
…dates. (microsoft#158398) Helps with microsoft#146768 but not a fix
@roblourens can you let me know what's the perf impact of calling this too many times. I.e. what's the underlying issue that blows up the memory usage. |
That method is called 10000 times with a payload that gets very large. vscode has to do a bunch of work to render an output from scratch on each iteration. It can't keep up and messages are written much faster than they are read by the renderer process. I was thinking this is basically the use-case that appendOutputItems was invented for. |
let's sync up tomorrow or debt week. i guess we can use a mix of both to optimize this scenario. let's sync during debt week |
Should be fixed with #161023 |
Steps to validate
# %% let's crash
import logging
for k in range(10_000):
logging.warning(k) |
Was this fixed? Windows 10 21H2 |
the fix will be in there next release, some time this week |
Hi,
since about 1-2 months ago, I cannot run many of my notebooks inside VS Code any more. When running certain cells, memory usage increases massively, eventually causing Windows to hang or terminate VS Code when all available RAM is taken.
Unfortunately I cannot share code due to IP issues and haven't yet came up with a minimal reproducible example. However, the issue seems to be quite often triggered by code that generates a bunch of matplotlib or plotly plots. I've seen it happen with other kinds of code too.
The issue occurs in both Insiders and regular VS Code. From Jupyter Lab the same code runs fine, no memory issues.
Running Windows 10 and latest VS Code releases.
The text was updated successfully, but these errors were encountered: