Heap out of memory error #9149
Replies: 1 comment 3 replies
-
|
This looks like Vitest is hitting V8 memory limits in its worker pool, while your code runs fine in a normal Node process. Likely causes:
Try these solutions: 1. Disable VM isolation: export default defineConfig({
test: {
isolate: false,
pool: "forks",
poolOptions: {
forks: { singleFork: true },
},
},
});2. Increase Node memory limit: NODE_OPTIONS="--max-old-space-size=4096" npx vitest run3. Use forks pool: 4. Debug the initialization: The "one additional word" clue: What kind of parser is this (NLP, programming language, etc.)? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using vitest with a typescript project. Fairly early on and I'm new to vitest, but it's been working well so far. However, I have hit a wall and I'm baffled.
I am running only one simple test and if I run it within the vitest harness, I get a JavaScript heap out of memory, but if I run the exact same code outside of vitest, it runs fine with no errors.
If I run the same test with a sentence that is a bit simpler, it works fine. Debug shows the memory used is minimal:
Before the parsing begins:
{"level":"debug","message":"Starting parse of sentence: 'The children are ready.'","timestamp":"2025-12-02T02:23:44.851Z"} {"arrayBuffers":811837,"external":4408972,"heapTotal":69435392,"heapUsed":46342568,"level":"debug","message":"Memory Usage (bytes):","rss":164937728,"timest\ amp":"2025-12-02T02:23:44.852Z"}After the parsing has finished:
{"arrayBuffers":943622,"external":4541422,"heapTotal":69697536,"heapUsed":50438520,"level":"debug","message":"Memory Usage after parse (bytes):","rss":16767\ 3856,"timestamp":"2025-12-02T02:23:45.130Z"}But if I add one additional word to the sentence (e.g., 'The first children are ready'), it fails during the initialization phase before the main parsing even begins. And again, this same sentence runs with no errors outside of vitest.
I upgraded from vitest 3.0.8 to 4.0.14 hoping that might help, but am still seeing the same issue. After upgrading to 4.0.14, I set vmMemoryLimit: '1024mb' in vitest.config.ts.
I really don't know how to figure out what is causing the issue and would appreciate any help!
Edit: I did one other thing and added debug to the initialization routine that fails so I could monitor how much the memory changes as I parse each word/part of speech. The changes are as expected and are very minimal. When I parse the sentence outside of vitest, it does bump the heapTotal slightly on the last word, but nothing unexpected. When I run it with vitest, that is the point where it fails with heap out of memory.
Beta Was this translation helpful? Give feedback.
All reactions