SandDance icon indicating copy to clipboard operation
SandDance copied to clipboard

vscode: "Allocation failed - JavaScript heap out of memory" for large dataset

Open bkmeneguello opened this issue 6 years ago • 4 comments

Besides a lot of RAM available this error happens when I try to open a large CSV file (803MB).

Console shows:

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: 0x562d86afdd15  [/usr/share/code/code]
 2: 0x562d86afde8a  [/usr/share/code/code]
 3: 0x562d837914f1  [/usr/share/code/code]
 4: 0x562d8383e6f2  [/usr/share/code/code] 
 5: 0x562d83846d04  [/usr/share/code/code]
 6: 0x562d83406f4c v8::internal::Factory::NewRawOneByteString(int, v8::internal::PretenureFlag) [/usr/share/code/code]
 7: 0x562d83866c64  [/usr/share/code/code]
 8: 0x562d837afe89 v8::String::Utf8Length(v8::Isolate*) const [/usr/share/code/code]
 9: 0x562d86b283ee  [/usr/share/code/code]
10: 0x562d83155781  [/usr/share/code/code]
11: 0x562d839ffd0e  [/usr/share/code/code]

bkmeneguello avatar Oct 11 '19 18:10 bkmeneguello

Hi @bkmeneguello, thanks for posting this. There will of course, be some maximum limit of what can be loaded / displayed. Currently, we don't know exactly what that limit is, but it is probably around 500k rows.

A followup issue, is that the app should fail more gracefully than crashing.

danmarshall avatar Oct 11 '19 20:10 danmarshall

Hi @danmarshall, thanks for your answer but where these limits come from? It's a js engine limitation or something that could be tuned? I have enough memory to accommodate all these data multiple times, so there could be possible to load lots of data (also for video memory). I understand if this can lead to performance issues since js is single threaded and workers aren't always an option.

bkmeneguello avatar Oct 12 '19 01:10 bkmeneguello

Hi @bkmeneguello, searching that error message, I see the there is a 1GB limit for Node.js heap size: https://github.com/nodejs/node/issues/17878#issuecomment-354138432

We probably need to have a chunking strategy instead of loading the entire file all at once.

danmarshall avatar Oct 13 '19 07:10 danmarshall

I'd be happy to take a PR for splitting the file into chunks. The backend code is here, and the frontend code is here

That will get us around this specific error message, but we may have the same buffer problem in the frontend, eventually. Not sure how to deduce what the limits of one's browser should be.

danmarshall avatar Oct 13 '19 08:10 danmarshall