berry icon indicating copy to clipboard operation
berry copied to clipboard

[Bug?]: Couldn't allocate enough memory on Windows x86

Open Brooooooklyn opened this issue 2 years ago • 12 comments

Self-service

  • [ ] I'd be willing to implement a fix

Describe the bug

Couldn't allocate enough memory during installation

To reproduce

https://github.com/Brooooooklyn/Image/runs/4786431120?check_suite_focus=true

Environment

Os: Windows 32 bit
Node: 16.13.2

Additional context

No response

Brooooooklyn avatar Jan 12 '22 12:01 Brooooooklyn

https://github.com/napi-rs/napi-rs/runs/4919807837?check_suite_focus=true very easy to reproduce

Brooooooklyn avatar Jan 24 '22 10:01 Brooooooklyn

Hi! 👋

This issue looks stale, and doesn't feature the reproducible label - which implies that you didn't provide a working reproduction using Sherlock. As a result, it'll be closed in a few days unless a maintainer explicitly vouches for it or you edit your first post to include a formal reproduction (you can use the playground for that).

Note that we require Sherlock reproductions for long-lived issues (rather than standalone git repositories or similar) because we're a small team. Sherlock gives us the ability to check which bugs are still affecting the master branch at any given point, and decreases the amount of code we need to run on our own machines (thus leading to faster bug resolutions). It helps us help you! 😃

If you absolutely cannot reproduce a bug on Sherlock (for example because it's a Windows-only issue), a maintainer will have to manually add the upholded label. Thanks for helping us triaging our repository! 🌟

yarnbot avatar Feb 23 '22 10:02 yarnbot

im having the exact same issue.

julianhille avatar Mar 07 '22 08:03 julianhille

I'm getting this issue using UTM/windows arm64 on a mac m1. Could we get the upholded label. I've tried upping memory up to 14GB but something tells me it's not the VM memory but perhaps shell or node configuration, because it happens very early in the install process.

Reproduction steps:

npx create-tamagui-app@latest
cd my-app
yarn
image

natew avatar Aug 04 '22 15:08 natew

Tried going all the way up to node --max-old-space-size=9900 C:\Users\n8\AppData\Roaming\npm\node_modules\yarn\bin\yarn.js but still get the errors, so thinking this isn't actually a system OOM thing.

Tried on VMWare and Parallels as well, same thing. Haven't tried x86 yet.

natew avatar Sep 08 '22 05:09 natew

Hello, I'm hitting this issue on Appveyors VMs which has node 18.12.0 (x86).
I can't reproduce the issue locally, but I made a minimal reproduction using appveyor:

https://ci.appveyor.com/project/Kuinox/appveyor-yarn-crash/builds/45458965

Build started
git clone -q --branch=main https://github.com/Kuinox/appveyor-yarn-crash.git C:\projects\appveyor-yarn-crash
git checkout -qf 41c3ac79c0a03c933a1cc12dc22835e53e17ef9d
node .yarn/releases/yarn-3.2.2.cjs
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0001: │ Error: Couldn't allocate enough memory
    at ZipFS.allocateBuffer ([worker eval]:1:42071)
    at ZipFS.allocateSource ([worker eval]:1:42507)
    at ZipFS.setFileSource ([worker eval]:1:42781)
    at ZipFS.writeFileSync ([worker eval]:1:47716)
    at extractArchiveTo ([worker eval]:1:463001)
    at async MessagePort.<anonymous> ([worker eval]:1:464372)
➤ YN0013: │ No packages were cached - 11 packages had to be fetched
➤ YN0000: └ Completed in 5s 109ms
➤ YN0000: Failed with errors in 5s 215ms
Command exited with code 1

As you can see, I'm not doing anything weird:
https://github.com/Kuinox/appveyor-yarn-crash
The crash is not 100% reproductible on this minimal reproduction, but it happens every single time on my regular projects (I suspect adding more dependencies will increase the chance of the bug being triggered).

Kuinox avatar Nov 22 '22 14:11 Kuinox

I just reproduced it in a Windows 11 Hyper-V VM on my desktop. I reproduced it with Node 18.2.1 (x86), but I can't reproduce it in Node 19 (x86).

Edit: I suspect something very bad is happening. I stopped to be able to reproduce the issue, so I restarted the VM, and now it fails in a very different way:

image

Edit 2: Cleaning the cache helps reproducing the issue more reliably.

With this new knowledge, I managed to reproduce without any VM, simply by cleaning the cache (cache clean --all) before running the restore with node 18 (x86).

Kuinox avatar Nov 22 '22 14:11 Kuinox

GitHub Actions also fails with "Couldn't allocate enough memory" when using yarn on Node x86 (which is the default on AppVeyor).

x64 works as expected.

bcrosnier avatar Nov 22 '22 15:11 bcrosnier

i never could fix it although digged very deep into the source of yarn. We started having it when using more and more workspace packages. And then i just switched back to npm, it was a day of pain by changing all the scripts but worth it.

Whoever has that issue locally, look at the process monitor and search for the node one. I witnessed some sort of recursive process calling. 1 node process with 16 MB, having a child yarn with 98 MB ram, having a child with another 67MB and then start all over at 16MB -> 98MB -> 67 MB until infinity.

julianhille avatar Nov 22 '22 16:11 julianhille

I'm able to reproduce this every time by using docker buildx build --platform linux/arm64 or linux/arm/v7. Something's up with the ZipFS (maybe wasm on ARM?).

As a workaround, I tried reducing the maxOpenFiles for every ZipOpenFs instance, which worked. The build didn't run out of memory, but oh boy was it slow. Only modifying the node-modules linker's maxOpenFiles also worked.

So to make it work, I just searched and replaced every maxOpenFiles:80 in .yarn/releases/yarn-3.6.0.cjs to maxOpenFiles:4 or maxOpenFiles:10 or something low until it worked.

cxcorp avatar Jun 13 '23 11:06 cxcorp

I'm able to reproduce this every time by using docker buildx build --platform linux/arm64 or linux/arm/v7. Something's up with the ZipFS (maybe wasm on ARM?).

As a workaround, I tried reducing the maxOpenFiles for every ZipOpenFs instance, which worked. The build didn't run out of memory, but oh boy was it slow. Only modifying the node-modules linker's maxOpenFiles also worked.

So to make it work, I just searched and replaced every maxOpenFiles:80 in .yarn/releases/yarn-3.6.0.cjs to maxOpenFiles:4 or maxOpenFiles:10 or something low until it worked.

i'm getting the same error Couldn't allocate enough memory in a fresh Ubuntu 23.04 Docker container using aarch64 and Node.js 20.6.1 and Yarn 3.6.3.

i'm using a Macbook Pro Max M2 and already configured Docker for Mac Settings to use up to 40 out of my 64Gb of memory

i tried your solution by running

sed -i 's/maxOpenFiles:80/maxOpenFiles:10/g' .yarn/releases/yarn-3.6.3.cjs

then tried installing dependencies again with the following

time yarn install --network-timeout 1000000000

then i still get error

➤ YN0001: │ Error: Couldn't allocate enough memory
    at ZipFS.allocateBuffer ([worker eval]:1:40610)
    at ZipFS.allocateSource ([worker eval]:1:41045)
    at ZipFS.setFileSource ([worker eval]:1:41318)
    at ZipFS.writeFileSync ([worker eval]:1:46409)
    at extractArchiveTo ([worker eval]:1:466938)
    at async MessagePort.<anonymous> ([worker eval]:1:468587)
➤ YN0000: └ Completed in 16s 266ms
➤ YN0000: Failed with errors in 45s 772ms

real	0m46.520s
user	0m22.146s
sys	0m7.962s

so i changed maxOpenFiles from 10 to 4 by running

sed -i 's/maxOpenFiles:10/maxOpenFiles:4/g' .yarn/releases/yarn-3.6.3.cjs

then tried installing dependencies again with the following again

time yarn install --network-timeout 1000000000

and got same error

➤ YN0001: │ Error: Couldn't allocate enough memory
    at ZipFS.allocateBuffer ([worker eval]:1:40610)
    at ZipFS.allocateSource ([worker eval]:1:41045)
    at ZipFS.setFileSource ([worker eval]:1:41318)
    at ZipFS.writeFileSync ([worker eval]:1:46409)
    at extractArchiveTo ([worker eval]:1:466938)
    at async MessagePort.<anonymous> ([worker eval]:1:468587)
➤ YN0000: └ Completed in 15s 289ms
➤ YN0000: Failed with errors in 42s 942ms

real	0m43.719s
user	0m21.505s
sys	0m7.707s

so lastly i changed maxOpenFiles from 4 to 1 by running the following and checking the file had changed

sed -i 's/maxOpenFiles:4/maxOpenFiles:1/g' .yarn/releases/yarn-3.6.3.cjs

then tried installing dependencies again with the following again

time yarn install --network-timeout 1000000000

and got same error

➤ YN0001: │ Error: Couldn't allocate enough memory
    at ZipFS.allocateBuffer ([worker eval]:1:40610)
    at ZipFS.allocateSource ([worker eval]:1:41045)
    at ZipFS.setFileSource ([worker eval]:1:41318)
    at ZipFS.writeFileSync ([worker eval]:1:46409)
    at extractArchiveTo ([worker eval]:1:466938)
    at async MessagePort.<anonymous> ([worker eval]:1:468587)
➤ YN0000: └ Completed in 14s 861ms
➤ YN0000: Failed with errors in 42s 292ms

real	0m43.046s
user	0m21.005s
sys	0m6.910s

ltfschoen avatar Sep 10 '23 00:09 ltfschoen