|
If your Jenkins started choking with OutOfMemoryError, there are four possibilities.
Which category your OutOfMemoryError falls into is not always obvious, but here are a few useful techniques to diagnose the problem.
If you think it's a memory leak, the Jenkins team needs to get the heap dump to be able to fix the problem. There are several ways to go about this.
Once you obtain the heap dump, please post it somewhere, then open an issue (or look for a duplicate issue), and attach a pointer to it. Please be aware that heap dumps may contain confidential information of various sorts. If the full heap dump is too big, please try to get us the heap histogram (jmap -histo:live pid). In the past, the distributed build support has often been a source of leakage (as this involves in a distributed garbage collection.) To check for this possibility, visit links like http://yourserver/jenkins/computer/YOURSLAVENAME/dumpExportTable. If this show too many objects, they may be leaks. Analyzing the heap dump yourselfIf you cannot let us inspect your heap dump, we need to ask you to diagnose the leak.
Report the summary of those findings to the list and we'll take it from there. Using VisualVMUnless you already have a preferred memory profiling tool, VisualVM is recommended for analyzing heap dumps. It is a standalone version of the NetBeans profiler, distributed with the Oracle JDK. Run jvisualvm and use File » Load and select the heap dump. In the Classes tab, look for a class with a suspiciously large number of instances, if not already identified by jmap -histo. For example, to debug a Groovy script leak, type GroovyClassLoader in the filter field and double-click the line with no $ in it (just groovy.lang.GroovyClassLoader). In the Instances tab you should now see all instances. Click on some at random. (If there are more than 500, they will be broken into groups of 500, with the first expanded; so to get a representative instance “from the middle”, collapse the first group, expand a group in the middle, and select some instance from that group.) Under References, right-click this and select Show Nearest GC Root. Right-click the selected item in the tree and select Copy Path From Root. Paste this text, for several examples, into a text file and attach it to a bug report—or continue your investigation into plugin source code. |
I'm getting OutOfMemoryError
Skip to end of metadata
Go to start of metadata
Comments (6)
Apr 11, 2012
Frank Merrow says:
Could you please add instructions for how to increase the heap space? I assume ...Could you please add instructions for how to increase the heap space?
I assume this the -Xmx parameter in Jenkins.xml . . . is that correct?
Do you have a recommended size based on number of jobs (or some other criteria)?
The default of -Xmx256m seems like a lot . . . some guidance on expected size would be nice.
I expect this is trivial for you Java Gods, but not so much for us C# folks. <wink>
May 09, 2012
rjohnst - says:
Hi Frank We're using Tomcat as our container, so the way we do it is to add a s...Hi Frank
We're using Tomcat as our container, so the way we do it is to add a setenv.sh script to our tomcat's bin directory, wherein we do the following things:
At any one time we'll have between 400 and 600 jobs active. Watching the garbage collection log is really the only way to tell what you need to do, not only to figure out how much memory to give Jenkins but also how to allocate that memeory to prevent the JVM from doing full GCs all the time, which will slow your Jenkins down...
Jun 08, 2012
Rob de Heer says:
I'm seeing a similar issue. We are using jenkins 1.435 with six executors....I'm seeing a similar issue. We are using jenkins 1.435 with six executors. All build jobs are slaved to the build server. When I start the slave agent on the build server, it immediately grabs about 4g of memory, and climbs from there. PID 3886 is the build slave agent.
VIRT PID USER PR NI RES SHR S %CPU %MEM TIME+ SWAP COMMAND
6418m 3886 svnbuild 20 0 685m 4332 S 9.0 4.3 47:07.20 5.6g java
4041m 6392 svnbuild 20 0 769m 4912 S 4.0 4.8 53:43.42 3.2g java
2033m 1931 root 20 0 8 4 S 0.0 0.0 0:00.48 2.0g console-kit-dae
977m 9385 svnbuild 20 0 141m 4732 S 0.0 0.9 66:26.71 835m java
The biggest problem we are seeing is that jobs are killed randomly, possibly because they can't get more memory.
I haven't combed through the heap to see what's taking most of the space.
Thanks,
Rob
Jun 25, 2012
Rob de Heer says:
We are still seeing this problem. After doubling available memory from 16 to 32 ...We are still seeing this problem. After doubling available memory from 16 to 32 gig, jenkins grabs almost all of the available memory. Here is a heap dump from the main slave process that runs most of our builds (about 100).
https://docs.google.com/open?id=0B1yvL2GloBmIQ1o0TkV2YmZOdDA
Here's the dumpExportTable https://docs.google.com/open?id=0B1yvL2GloBmIZ1ZqUWpjM1JpLWs
We also found that setting xmx on the slave to 4 gig slowed jenkins to a crawl.
Any insights would be appreciated.
Rob
Sep 04, 2013
alexanderlink - says:
There is another type of OutOfMemoryError which is not necessarily related to me...There is another type of OutOfMemoryError which is not necessarily related to memory: "java.lang.OutOfMemoryError: unable to create new native thread".
We currently struggle with this since on our Mac for some reason the native thread limit is about 2000 (in tests I got this exception after 2025 java threads) and our Jenkins has about 1800 threads and more.
May 07, 2014
Piotr Tokaj says:
"To check for this possibility, visit links likehttp://yourserver/jenkins/comput..."To check for this possibility, visit links likehttp://yourserver/jenkins/computer/YOURSLAVENAME/dumpExportTable. If this show too many objects, they may be leaks."
How many is too many?
Also, if I believe I have a memory leak caused by distributed builds, how do I go about fixing that?
Add Comment