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

Native-image of CLI application is failing with less than 32 GB of virtual memory #8476

Closed
munishchouhan opened this issue Feb 29, 2024 · 11 comments
Assignees

Comments

@munishchouhan
Copy link
Contributor

munishchouhan commented Feb 29, 2024

Describe the issue
Our CLI native-image is failing when there is less than 32 GB of virtual memory

Steps to reproduce the issue
Please include both build steps as well as run steps

  1. Download https://github.com/seqeralabs/wave-cli/releases/download/v1.2.0/wave-1.2.0-linux-x86_64
  2. run: (ulimit -v 33603487; ./wave-1.2.0-linux-x86_64 --version)

Describe GraalVM and your environment:

  • GraalVM version : graalvm-jdk-21.0.2+13.1
  • JDK major version: 21
  • OS: Ubuntu 22.04.1
  • Architecture: AMD64

More details
Build logs:
https://github.com/seqeralabs/wave-cli/actions/runs/8005072271/job/21863704006

Source code of application:
https://github.com/seqeralabs/wave-cli/

we have already set the heap size:
https://github.com/seqeralabs/wave-cli/blob/b47f31f54c64aa8d1f1b2d1d20443d939e3c9eee/app/build.gradle#L86-L89

Error:

~$ (ulimit -v 33603487; ./wave-1.2.0-linux-x86_64 --version)
Fatal error: Failed to create the main Isolate. (code 801)
~$ (ulimit -v 33603488; ./wave-1.2.0-linux-x86_64 --version)
1.2.0_b47f31f
@solaanan
Copy link

solaanan commented Mar 1, 2024

Hello @munishchouhan, Thank you for reporting this issue, I will try to reproduce and get back to you soon.

@munishchouhan
Copy link
Contributor Author

hi @solaanan If you have any update in this issue, please share

@solaanan
Copy link

solaanan commented Apr 1, 2024

Hello @munishchouhan, we apologize for the delay, we are still investigating the issue, but in the meantime can you verify if the issue still persists using the latest release Oracle GraalVM 24.0.0 for JDK 22?

@fniephaus
Copy link
Member

Thanks for raising this ticket, @munishchouhan! It seems you ran into a current limitation of the compressed references feature that Oracle GraalVM provides for the default Serial GC. We are aware of this problem and will fix this soon. In the meantime, there are two ways you can work around this:

  1. Use the G1 GC via --gc=G1. Maybe that's even the better GC for your application if you care for low latency and high throughput
  2. Disable compressed references via -H:-UseCompressedReferences if you want to keep using Serial GC. Note that this might increase your applications memory consumption.

Hope this helps!

@munishchouhan
Copy link
Contributor Author

@fniephaus thanks a lot, I will check out these options

@munishchouhan
Copy link
Contributor Author

using g1gc solves the problem, closing it now

@peter-hofer
Copy link
Member

@munishchouhan , this is only about an address range that is reserved ahead of time, in general the occupied physical memory will be a small fraction (depending on the application's behavior). Where does this limit come from? The referenced build logs are no longer available.

@munishchouhan
Copy link
Contributor Author

@peter-hofer here is the original issue
seqeralabs/wave-cli#46
When using this cli application in a machine with limited memory, we saw the Fatal error: Failed to create the main Isolate. (code 801). After trying to restrict the virtual memory, we could reproduce this issue on other machines, too. I have used ec2 t2.micro ubuntu to test it.

@peter-hofer
Copy link
Member

@munishchouhan Thanks. Yes, restricting virtual memory will trigger this. But why restrict virtual memory in the first place? It is just an abstract concept, a table of address ranges. There is no potential shortage unlike with physical memory. It makes more sense to restrict the resident set size.

@munishchouhan
Copy link
Contributor Author

@peter-hofer This issue came from a virtual machine with low physical memory. Virtual memory was restricted to reproduce the issue in any machine. Please take a look at this comment seqeralabs/wave-cli#46 (comment)

@peter-hofer
Copy link
Member

@munishchouhan you can use -R:ReservedAddressSpaceSize=<nbytes> during the image build or at runtime to restrict the size of the reserved virtual address space, for example to a value of 1073741824 (1GB). While G1GC seems to not have this issue, SerialGC should be sufficient for a command-line tool and result in a smaller image. This issue should also currently not occur with GraalVM Community Edition, although we might be moving to reserving an entire heap address space there soon as well.

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

4 participants