Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins build throwing an out of memory error

We have Jenkins running on an ec2 instance. When doing a build, we see the following error:

17:29:39.149 [INFO] [org.gradle.api.Project] OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000007ac000000, 234881024, 0) failed; error='Cannot allocate memory' (errno=12)
17:29:39.150 [INFO] [org.gradle.api.Project] #

17:29:39.150 [INFO] [org.gradle.api.Project] # There is insufficient memory for the Java Runtime Environment to continue.

17:29:39.150 [INFO] [org.gradle.api.Project] # Native memory allocation (malloc) failed to allocate 234881024 bytes for committing reserved memory.

I researched on this topic and tried various settings such as increasing the heap memory, ram and PermGenSize. Here is my current memory setting on Jenkins:

-Xms256m -Xmx2048m -XX:MaxPermSize=512m

Are there any other things that I'm missing that's causing an OOM?

like image 604
Satya Avatar asked Jun 25 '15 04:06

Satya


People also ask

How do I resolve out of memory error in Jenkins?

OutOfMemoryError: Heap space – this means that you need to increase the amount of heap space allocated to Jenkins when the daemon starts. java. lang. OutOfMemoryError: PermGen space – this means you need to increase the amount of generation space allocated to store Java object metadata.

How much RAM does Jenkins need?

Minimum hardware requirements: 256 MB of RAM. 1 GB of drive space (although 10 GB is a recommended minimum if running Jenkins as a Docker container)


2 Answers

I've sold the same problem. (I have ec2, t2.micro, Ubuntu 14, Jenkins, Tomcat, Maven). By default you don't have swap space. To confirm this:

free -m

Just add some. Try with 1 GB for begin.

sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

Check again:

free -m

For more details look here

like image 86
Optio Avatar answered Oct 15 '22 18:10

Optio


This is not a memory issue on JVM level, but on OS level. The JVM tries to allocate 224MB, but this amount of memory isn't available on OS level. This happens when the -Xmx settings of a JVM are larger than the amount of free memory in a system. Check the amount of free memory in the OS, and either limit the memory of your current JVM so that fits within the free memory, or try to free up memory (by limiting the amount of memory other processes use) or try out an EC2 instance with more memory.

like image 31
Bert Jan Schrijver Avatar answered Oct 15 '22 18:10

Bert Jan Schrijver