Skip to content
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

Compiling arm gcc crashes on wsl 2 because virtual memory exhausted #5295

Closed
gabrieldds opened this issue May 29, 2020 · 4 comments
Closed

Comments

@gabrieldds
Copy link

Microsoft Windows [version 10.0.19041.264]

I have tried compile arm gcc for a personal project on wsl 2, but compilation crashes because this:

cc1plus: out of memory allocating 65536 bytes after a total of 3624960 bytes

cc1plus: out of memory allocating 259737 bytes after a total of 2277376 bytes
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-9/README.Bugs> for instructions.
virtual memory exhausted: Cannot allocate memory
virtual memory exhausted: Cannot allocate memory
virtual memory exhausted: Cannot allocate memory
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
cc1plus: internal compiler error: Aborted
make[2]: *** [Makefile:2361: s-attrtab] Error 1
virtual memory exhausted: Cannot allocate memory
virtual memory exhausted: Cannot allocate memory
virtual memory exhausted: Cannot allocate memory

I already have compiled same project on ubuntu and arch linux, but this is happening and i didn't find any issues of how solve this. It seems that wsl doesn't free memory allocated by program. Any help with this?

@onomatopellan
Copy link

onomatopellan commented May 29, 2020

When that happens do free -h and post the output.

Also post the entire command you use to compile.

@therealkenc
Copy link
Collaborator

If your building with make -j dial it back to -j1 (or no -j) to start, and creep up from there. Compiling gcc doesn't actually take that much memory except for the link phase. Hovering around ~600-750MiB for me with one concurrent job.

image

@gabrieldds
Copy link
Author

Well, i put 12 gb on swap and now i think it's working, but now this is result of free -h:

total        used        free      shared  buff/cache   available
Mem:          3.8Gi       3.0Gi       542Mi       0.0Ki       351Mi       681Mi
Swap:          12Gi       4.9Gi       7.1Gi

Yes, i'm compilling with make -j4, i will try just make. Thanks.

@therealkenc
Copy link
Collaborator

Yeah 4GiB is cutting it pretty close for a -j4. Old trick: let it build with (say) -j4. Watch it run out of memory. Get over the hump with -j1 (usually a link phase). Then ctrl-c, and start it back up with -j4. Repeat. I've done that with chromium builds, which can take over 32GiB to link.

But in your case with 4gb, probably just -j2, cross fingers, and be patient. The different is not worth the dance. Don't let it swap if you can. Your patience will probably run out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants