OutOfMemory Problems
If you experience problems with TeamCity "eating" too much memory or OutOfMemoryError/"Java heap space" errors in the log, please do the following:
- Determine what process encounters the error (the actual building process, the TeamCity server, or the TeamCity agent). Since TeamCity 8.1.2, you can track memory and CPU usage by TeamCity with the charts on the Administration | Server Administration | Diagnostics page of your TeamCity web UI.
- If the server is to blame, please check you have increased memory settings from the default ones for using the server in production (see the section).
- If you use x64 JVM, please consider using 32 bit JVM, as it will require less memory (instructions for server).
- Try to increase the memory for the process via '-Xmx' JVM option, like -Xmx1200m. If the error message is "java.lang.OutOfMemoryError: PermGen space", increase the value in -XX:MaxPermSize=270m JVM option.
The option needs to be passed to the process with problems:- if it is the building process itself, use "JVM Command Line Parameters" settings in the build runner. e.g. Inspections builds may specifically need to increase the parameter;
- refer to the corresponding documentation for TeamCity server or agent. See also Installing and Configuring the TeamCity Server;
- If the TeamCity server is to blame and increasing the memory size does not help, please report the case for us to investigate. For this, while the server is high on memory consumption, take several server thread dumps as described above, get the memory dump (see below), archive the results and send them to us for further analysis. If you have increased the Xmx setting, please reduce it to the usual one before getting the dump (smaller snapshots are easier to analyze and easier to upload):
- to get a memory dump (hprof file) automatically when an OutOfMemory error occurs, add the following server JVM option (works for JDK 1.5.0_07+): -XX:+HeapDumpOnOutOfMemoryError. When OOM error occurs next time, the java_xxx.hproffile will be created in the process startup directory (<TeamCity home>/bin or <TeamCity Agent home>/bin);
- you can also take memory dump manually when the memory usage is at its peak. Go to the Administration | Server Administration | Diagnostics page of your TeamCity web UI and click Dump Memory Snapshot.
- another approach to take a memory dump manually is to run the TeamCity server with JDK 1.6+ and use the jmap standard JVM util. e.g. jmap -dump:file=<file_on_disk_to_save_dump_into>.hprof <pid_of_your_TeamCity_server_process>
Please sign in to leave a comment.