Reputation:
I'm using Teamcity to run CI which works great, apart from one thing: when my webapp is deployed to the web container (Tomcat 5.5) after a few times Tomcat runs out of memory. This is something that you see in development as well, but it's not such a huge problem since then you can restart manually any way - with CI it's all automatic which makes it really annoying.
I tried to setup Teamcity so that it restarts Tomcat every deploy, but then I ran into another problem - the Tomcat start script just hangs when called from ant (ie it starts Tomcat just fine, but then doesn't go any further in the build-process).
Anyone out there with a similar Teamcity-Tomcat setup?
Upvotes: 1
Views: 1341
Reputation: 5664
I'd guess that this problem isn't specific to TeamCity.
How are you calling the Tomcat startup script from Ant?
If you're using the "exec" task you probably need to set the "spawn" attribute to true so that it spawns Tomcat in another process. Otherwise Ant is waiting for the process to end before it continues.
In our deployments we have a script which checks permgen levels and (optionally) restarts Tomcat if the permgen is too high.
Upvotes: 0
Reputation: 26769
We had exactly the same issue, and as Mark Robinson points out, it's to do with classes not getting garbage collected.
The particular issue we had was lots of static stuff getting loaded: log4j, spring contexts stuffed in static globals, and other class libraries that created static instances or singletons.
It was possible to trace down a lot of these using a profiler, and then explicitly deal with resource cleanup in the servlet's destroy()
method. Although this didn't totally solve the problem, it did relieve some of it.
In the end we added an additional pair of ant targets to stop and start Tomcat, and wrapped the build process in these. YMMV.
Upvotes: 0
Reputation: 17132
It's an issue with tomcat, the classloader and the classes are not being garbage collected properly. Every time you reload the webapp context, more copies of these classes are loaded, and as these are stored in the permanent heap generation, it will eventually run out of memory.
You can increase the PermGen size on tomcat startup, this will only allow you to re-deloy more times with out running out of memory, it's not really a fix but you can increase the number of deploys until you'll have to restart.
Upvotes: 1