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

Bug: There is insufficient memory for the Java Runtime Environment to continue. #26

Closed
fx10007 opened this issue Sep 25, 2023 · 3 comments

Comments

@fx10007
Copy link

fx10007 commented Sep 25, 2023

What happened?

description:kafka failed to start when deploying with docker compose

kafka | # There is insufficient memory for the Java Runtime Environment to continue.
kafka | # Native memory allocation (mmap) failed to map 1073741824 bytes for committing reserved memory.
kafka | # An error report file with more information is saved as:
kafka | # //hs_err_pid31767.log
kafka | OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c0000000, 1073741824, 0) failed; error='Not enough space' (errno=12)
kafka | Waiting for Kafka to be ready...
kafka | OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c0000000, 1073741824, 0) failed; error='Not enough space' (errno=12)
kafka | #
kafka | # There is insufficient memory for the Java Runtime Environment to continue.

What did you expect to happen?

error='Not enough space'

How can we reproduce it (as minimally and precisely as possible)?

system:Ubuntu 18.04.6 LTS
cpu:2vCPU x86_64
internal storage:2 GiB
disk:40G

Anything else we need to know?

No response

version

```console $ {openim-docker} version # 3 ```

Cloud provider

aliyun

OS version

```system:Ubuntu 18.04.6 LTS cpu:2vCPU x86_64 internal storage:2 GiB disk:40G ```

Install tools

@kubbot
Copy link
Contributor

kubbot commented Sep 25, 2023

Hello! Thank you for filing an issue.

If this is a bug report, please include relevant logs to help us debug the problem.

Join slack 🤖 to connect and communicate with our developers.

@fx10007
Copy link
Author

fx10007 commented Sep 25, 2023

root@iZuf66n8glfluybzq5n6r3Z:~/openim/openim-docker# df -h
Filesystem Size Used Avail Use% Mounted on
udev 915M 0 915M 0% /dev
tmpfs 190M 8.2M 182M 5% /run
/dev/vda3 40G 13G 26G 33% /
tmpfs 948M 0 948M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 948M 0 948M 0% /sys/fs/cgroup
/dev/vda2 189M 4.4M 184M 3% /boot/efi
tmpfs 190M 0 190M 0% /run/user/0
overlay 40G 13G 26G 33% /var/lib/docker/overlay2/28ea4ddf7a47a5d1c5b6563059dcf69df07ef5c42e8413602265f1e0d88fd37d/merged
overlay 40G 13G 26G 33% /var/lib/docker/overlay2/9cfb387bdcef08fcb1c6198729ad624390b0c32992fe1b67317b06f7c973a7bf/merged
overlay 40G 13G 26G 33% /var/lib/docker/overlay2/53870e12bc23ab1ab7a24795afb8f1b93a09fd52dc59dcdcc1462a6238484d83/merged
overlay 40G 13G 26G 33% /var/lib/docker/overlay2/e7bbede314bb4c36de338acf41a9afaf79cffae5aceb246724eb790d72bd065e/merged
overlay 40G 13G 26G 33% /var/lib/docker/overlay2/0ff0aabdf34511883de03ac7742fdaef222a642d2873a7671333f54fa7ee6785/merged
overlay 40G 13G 26G 33% /var/lib/docker/overlay2/26cbda52683843676add8137763f7b97a160fe7678ec2d1b4e06b59d8429da1f/merged
overlay 40G 13G 26G 33% /var/lib/docker/overlay2/093379f62087c591b6ac598d98c827fc66071a0e514d220cff6736c9b4a23850/merged
overlay 40G 13G 26G 33% /var/lib/docker/overlay2/606de16cae472ed0c9bbd6e445b91a61ac1614e53ea6befb0f7bf4383e9c90b4/merged
overlay 40G 13G 26G 33% /var/lib/docker/overlay2/5c6c6e287a375d850558825ff2a353f4a907a579e6eb3258d63080e8162b77cd/merged
overlay 40G 13G 26G 33% /var/lib/docker/overlay2/c858ccdae71d9df421255352201b0fc58be105349f09e78d39e41d297ea6418d/merged
overlay 40G 13G 26G 33% /var/lib/docker/overlay2/6d9085eef0bbbb316cd79d313fc5d90d1cb4a8f49fbf6ed9b9d4546290f92a69/merged

@cubxxw
Copy link
Contributor

cubxxw commented Sep 25, 2023

Issue Analysis

Your Kafka service, when deployed with Docker Compose, fails to start due to memory constraints. Here are the key points from the error:

  • There is insufficient memory for the Java Runtime Environment to continue.: This indicates that the Java runtime environment lacks adequate memory to proceed.
  • Native memory allocation (mmap) failed to map 1073741824 bytes for committing reserved memory.: Native memory allocation is trying to map 1GB of memory but is unsuccessful.
  • Your system has 2GB RAM, and Kafka is attempting to use 1GB, which might be straining the available memory, especially considering the OS and other processes also require memory.

Solutions

  1. Increase RAM: If you're operating in a cloud environment, consider resizing your instance to have more RAM. More RAM will alleviate the memory constraints faced by Kafka.

  2. Optimize Java Heap Size: Adjust Kafka's Java heap size settings. You can set the maximum heap size for JVM (using the -Xmx option). Ensure that the memory allocated to Kafka is less than the total memory, leaving some breathing space for the system and other processes.

    KAFKA_HEAP_OPTS="-Xmx768m -Xms256m"
    
  3. Monitor Other Processes: Use tools like top or htop to see which processes consume significant memory. Consider if some of them can be stopped to free up memory.

  4. Startup Order: If you have multiple services in your docker-compose file, ensure Kafka isn't starting first. Let other lower-memory consuming services start before Kafka.

@fx10007 fx10007 closed this as completed Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants