What should be the value of TEAMCITY_AGENT_MEM_OPTS? I'm getting "JVM crashed" error

Hi All,

I'm getting "JVM crashed" error when running Scala unit tests (using SBT).

[19:54:54][Step 2/2] Error during tests:
[19:54:54][Step 2/2]  Running java with options sbt.ForkMain 64035 failed with exit code 1
[19:55:29][Step 2/2] # There is insufficient memory for the Java Runtime Environment to continue.
[19:55:29][Step 2/2] # Native memory allocation (malloc) failed to allocate 990256 bytes for Chunk::new
[19:55:29][Step 2/2] # An error report file with more information is saved as:
[19:55:29][Step 2/2] # D:\TC8Agent1\work\53dfd62ac34dc736\src\hs_err_pid6216.log

The tests are running on a build agent on a Windows 2008 R2 server with 8GB or RAM.
The server holds the TeamCity server, and two build agents.

The TeamCity server memory usage is set to:
TEAMCITY_SERVER_MEM_OPTS = -Xmx3g -XX:MaxPermSize=270m

Anyone has recomendation for the value of TEAMCITY_AGENT_MEM_OPTS so that the unit tests won't crush the JVM?

This value is for each build agent on the server, I am not sure what should the values be when the two TeamCity agents and TeamCity server are on the same host.


Comment actions Permalink

Hi Eyal,

It is not recommended to install TeamCity agents and TeamCity server on the same host.

TEAMCITY_AGENT_MEM_OPTS is effective only for an agent's JVM. Agent is working in the JVM, when Java based build is started a new JVM is created and build is running in this JVM. This JVM has memory settings defined in the corresponding build configuration. The agent settings aren't propagated to build process JVM. So altering them doesn't take any effect on builds.
Does the build fail if you run it on the same agent via command line (not using TeamCity)?

Comment actions Permalink

Hi Alina,

Thanks for the quick reply.

I cannot run the build from the commandline because it is an SBT build.

SBT is not installed on the agent, it is a plugin bundled in TeamCity.

I'll move the builds agent to another server so that the agents are not on the TeamCity server itself.


Comment actions Permalink

SBT should be installed on the agent. There is an option in the SBT runner build step"SBT installation mode". When the default <Auto> option is selected, the latest SBT version is installed on every TeamCity agent your build will be running. Or you can specify an existing installation using the <Custom> mode. In this case the

from the
directory of the SBT home will be launched.

Please sign in to leave a comment.