How to run TeamCity on 64-bit JVM
Asked Answered
E

3

10

I've just found out that TeamCity runs on the 32-bit JVM on Windows, for some reason.

I'm seeing memory errors logged when checking out a large (not that large) Git repo and am already at the max heap size for the JVM. I know nothing about Java or the JVM, or TomCat.

How can I run TeamCity on a modern, 64-bit JVM? I sense its going to be a pain, else it would be the default.

We're a tiny team and if something doesn't have Apple levels of 'it just works' then we skip it.

We can live with this one project not be on the CI server, but it would be nice to know what's involved and weigh up the investment.

Any advice appreciated.

Edit

Okay so Markus pointed to this snippet (which I had read), but I can't see any information there explaining what to do.

Using 64 bit Java to Run TeamCity Server TeamCity can run under both 32 and 64 bit JVM. It is recommended to use 32 bit JVM unless you need to dedicate more than 1.3Gb of memory to the TeamCity process.

If you choose to use x64 JVM please note that the memory usage is almost doubled when switching from 32 to 64 bit JVM, so please make sure you specify at least twice as much memory as for 32 bit JVM, see Setting Up Memory settings for TeamCity Server.

If you run TeamCity as a service and switch to x64 bit, you will also need to use x64 Tomcat executables, see more.

Did I miss something?

Edit 2

Ah, okay, buried in some paragraphs above that link is this:

"if you run as Windows service and want to upgrade JRE to 64 bit version, you will need to replace \jre with appropriate JRE"

So I guess I need to copy some files into the /jre folder?

Escobedo answered 8/11, 2013 at 17:51 Comment(1)
confluence.jetbrains.com/display/TCD7/…Assignation
A
2

The snippet from the updated question had a link in the original, pointing to the instructions on Java update for TeamCity server in TeamCity online doc.

Basically, the instructions vary based on the TeamCity distribution used and way of launching the server.

If your intent is to increase the memory for the TeamCity server, please make sure to read through the corresponding section on the same doc page.

Yet one more note: recent TeamCity versions perform Git fetch in a separate process and Git-related memory issues during fetch might require fine-tuning of the corresponding options.

Aiguillette answered 15/11, 2013 at 17:34 Comment(3)
Note to self: Had to check back after installing 8.1 since it overwrote the JRE. Need to install Java 1.7 64-bit and then copy the Program Files/jre7 folder to an empty TeamCity\jre folder.Escobedo
That's a helpful note. I landed here because my MSSQL connection was failing after a TeamCity upgrade and it turned out it was due to the upgrade reverting the JRE to a 32-bit version.Meissner
@LukePuplett, is there nothing else to it? Just install Java 64-bit using the installer and then overwrite the contents of the TeamCity\jre folder? It seems too easy to be true...Unwish
S
7

The way I made it work (TeamCity 8, Windows server 2008 r2):

  • Install the 64-bit JRE on the target machine, now there are two ways to do this

  • A -> If you are using the Teamcity bundled JRE, replace the JRE folder ([TC Server folder]\JRE) with the JRE folder in the newly installed JRE x64 - You have to shut down the TC server service (along with all java.exe*32 services that might also use this JRE)

  • B -> Change the TeamCity Internal properties, to point to newly installed JRE x64 (see documentation for TC version 8, TC version 9 can be found here):

    java.home=C\:\\<JRE x64 install folder>\\jre
    java.ext.dirs=C\:\\<JRE x64 install folder>\\jre\\lib\\ext\;C\:\\Windows\\Sun\\Java\\lib\\ext 
    java.library.path=C\:\\<JRE x64 install folder>\\jre\\bin\;C\:\\Windows\\Sun\\Java\\bin\;C\:\\Windows\\system32\;C\:\\Windows\;C\:\\local\\Oracle\\clients\\112_64\\bin\;C\:\\local\\Oracle… 
    
  • An alternative to point B would be to change Environment variable JAVA_HOME, it`s more simple, but it requires a Windows server restart after that

  • If you run the TC Server service now, it should run as a 64-bit Java process (chceck via PID in task manager) :

Resource  Monitor Task Manager

Snitch answered 1/12, 2014 at 9:2 Comment(2)
On TeamCity 8.1.5, I did want to use my local 64 bits JRE. Just setting the env var JAVA_HOME was not enough, I also had to rename the <TeamCityRoot>/jre to jre.old in order for the server to use the 64 bits JRE.Martini
Thanks @Vilmir, this workaround worked for me also with TeamCity 2017.2.2.Colossal
A
2

The snippet from the updated question had a link in the original, pointing to the instructions on Java update for TeamCity server in TeamCity online doc.

Basically, the instructions vary based on the TeamCity distribution used and way of launching the server.

If your intent is to increase the memory for the TeamCity server, please make sure to read through the corresponding section on the same doc page.

Yet one more note: recent TeamCity versions perform Git fetch in a separate process and Git-related memory issues during fetch might require fine-tuning of the corresponding options.

Aiguillette answered 15/11, 2013 at 17:34 Comment(3)
Note to self: Had to check back after installing 8.1 since it overwrote the JRE. Need to install Java 1.7 64-bit and then copy the Program Files/jre7 folder to an empty TeamCity\jre folder.Escobedo
That's a helpful note. I landed here because my MSSQL connection was failing after a TeamCity upgrade and it turned out it was due to the upgrade reverting the JRE to a 32-bit version.Meissner
@LukePuplett, is there nothing else to it? Just install Java 64-bit using the installer and then overwrite the contents of the TeamCity\jre folder? It seems too easy to be true...Unwish
S
1

"So I guess I need to copy some files into the /jre folder?"

No. You install a 64 bit JRE, and update the relevant setting to point at the 64-bit install's JRE.

Don't copy stuff from one JRE installation into another. You will break things!

Skillful answered 8/11, 2013 at 18:31 Comment(2)
Hi Stephen, it did actually include copying files. I'm not a Java guy but I get the feeling TeamCity on Windows doesn't do things like how a normal Windows Java app does. Renaming the old TeamCity/jre folder and replacing it with a copy from a newly-installed JRE folder worked and was the process JetBrains recommends.Escobedo
Simplest solution is to make sure a JAVA_HOME environment variable is set. Then shutdown TeamCity and any other Java process using TeamCity's embedded JRE; you might have to go to task manger to kill those processes off. Then rename the 'jre' folder in TeamCity to something like 'jre_dist' and restart TeamCity. If you want to use a different memory value, add the environment variable TEAMCITY_SERVER_MEM_OPTS and set the memory settings you would like, if TeamCity is running when adding this environment variable, restart TeamCity. Agents are more complicated and a different question.Primalia

© 2022 - 2024 — McMap. All rights reserved.