Changing java memory option is not taking the OS variable TEAMCITY_SERVER_MEM_OPTS

Answered

We have a TeamCity server installed and running in a VM. Recently we had some memory issues, so we plan to increase the memory to `1.5g` from `1g` . When we set the variable TEAMCITY_SERVER_MEM_OPTS in the env TeamCity is not picking up. 

details:

1. Version build 99542

2. OS: Amazone Linux VERSION_ID="2018.03"

3. Teamcity is running as a `xyz` user and env is set for that profile correctly

 

FIX:

Changed the value in the restart script teamcity-server-restarter.sh 

TEAMCITY_SERVER_MEM_OPTS="-Xmx1536m"

 

Problem:
When we upgrade the teamcity the binaries will be overriden by the new scripts. 

 

How can we make sure the memory setting in the environment variable is getting used ? 

0
3 comments

Hi Ajith,

You shouldn't modify any scripts in the bin directory of TeamCity installation. The default scripts will always correctly pick up the value of this variable. 

When we set the variable TEAMCITY_SERVER_MEM_OPTS in the env TeamCity is not picking up. 

Exactly how do you start the TeamCity server? Do you use the below command? Is it the original script, or it was modified? Do you use any tools like systemd to automatically start it? If so, what's the service description?

$ teamcity-server.sh start

On a side note, if your server is not really small, you should consider using the 2048m value, because 1536m is just above the minimum recommended setting for 64-bit Java (1024m). You can read more about recommended memory settings in this article

0

Hello Mikhail,

Whenever we change the environment variable we have to restart from the cli ? so memory settings will be set up before teamcity starts,as they are used to run the JVM. I was using UI to restart that's why it was not picking up ? 

Thanks for the suggestion on memory size.

Thanks,

Ajith

0

Hi Ajith,

That's right. When you restart the server using the 'Restart Server' button on the 'Administration | Diagnostics' page, any changes in the environmental variables are ignored.

The restart process doesn't kill the top-level process that starts the server (teamcity-server.sh). Since the parent process doesn't restart, neither it nor any of its child processes are aware of any environmental changes. 

In order for the new value to be picked up, you should stop the server (teamcity-server.sh stop) and then start it again (teamcity-server.sh start).

0

Please sign in to leave a comment.