1

My Dockerfile

FROM openjdk:8-jre-alpine
COPY ./service-0.0.1-SNAPSHOT-app.jar /app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-Xms1536m", "-Xmx1536m", "-XX:+UseConcMarkSweepGC", "-XX:CMSInitiatingOccupancyFraction=70", "-XX:+UseCMSInitiatingOccupancyOnly", "-verbose:gc", "-jar", "-Dspring.profiles.active=${ENV_NAME},${ENV_VERSION_NAME}", "/app.jar"]

My container run command

docker run -P -e ENV_NAME=dev -e ENV_VERSION_NAME=dev 7f25fb4baf24

Docker logs output

[GC (Allocation Failure)  419456K->48832K(1520448K), 0.0318446 secs]
[GC (Allocation Failure)  468288K->85028K(1520448K), 0.2128481 secs]
[GC (CMS Initial Mark)  94900K(1520448K), 0.0051537 secs]

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::       (v1.5.14.RELEASE)

Additional info:

  1. Docker run -ti doesn't help
  2. Above result is from running on Jenkins Slave, but runs fine on local machine and another Jenkins instance that Im trying to migrate from
  3. Other docker containers run fine on this Jenkins slave
  4. I see GC (Allocation Failure) even when running locally where app runs fine

1 Answers1

0

Does this Jenkins instance have enough RAM left?

Heap is taking 1520 MB as seen in your GC log and configured using Xms and Xmx setting.

XX:ReservedCodeCacheSize defaults to 240 MB.

Spring boot embedded tomcat creates 200 threads by default. This is configurable using configuration server.tomcat.threads.max=50. Each thread takes default stack size of 1 MB. So all threads will take 200 MB. Stack size can be configured using -Xss512k if needed.

So your app at would seek at least 1520+240+200=1960 MB free memory.

Your container will by default have visibility to all the RAM on your system and will try to grow itself when process running inside needs. You can limit the RAM visible to Java process by configuring XX:MaxRAM.

Answers for following question should also help you understand more on this: Java using much more memory than heap size (or size correctly Docker memory limit)

CoderPraBhu
  • 346
  • 3
  • 9