# SBT is failing with OutOfMemory in recent circleci/openjdk:8\* images when building a Docker image locally

**URL:** <https://discuss.circleci.com/t/sbt-is-failing-with-outofmemory-in-recent-circleci-openjdk-8-images-when-building-a-docker-image-locally/27572>\
**Category:** Build Environment\
**Created:** [January 10, 2019, 5:02pm UTC](https://discuss.circleci.com/t/sbt-is-failing-with-outofmemory-in-recent-circleci-openjdk-8-images-when-building-a-docker-image-locally/27572 "2019-01-10T17:02:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevinwright](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/kevinwright/32/10618_2.png) [@kevinwright](https://discuss.circleci.com/u/kevinwright)\
**Post date:** [January 10, 2019, 5:02pm UTC](https://discuss.circleci.com/t/sbt-is-failing-with-outofmemory-in-recent-circleci-openjdk-8-images-when-building-a-docker-image-locally/27572/1 "2019-01-10T17:02:16Z")

</div>

Using a even minimal docker file:

```
FROM circleci/openjdk:8u181-jdk
RUN sbt sbtVersion

```

and

```
docker build .

```

In a directory containing only the `Dockerfile`, I get a `java.lang.OutOfMemoryError: GC overhead limit exceeded`

This also happens with more complicated Dockerfiles, the example above was just the smallest example in which I could reproduce the problem when diagnosing.

I’ve tried several tagged versions starting `circleci/openjdk:8` - all have failed with the same error

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [January 10, 2019, 6:45pm UTC](https://discuss.circleci.com/t/sbt-is-failing-with-outofmemory-in-recent-circleci-openjdk-8-images-when-building-a-docker-image-locally/27572/2 "2019-01-10T18:45:07Z")

</div>

Unless you have changed it, you will be limited to 4G of RAM in the Docker Executor. However, if you are on a paid tier, [you can request larger limits](https://circleci.com/docs/2.0/configuration-reference/#resource_class).

If you are on the free tier, you can switch to a [Machine Executor](https://circleci.com/docs/2.0/executor-types/#using-machine), which will give you a 8G limit, and presently this option is free of charge. You can either use the bare VM as-is, or install Docker yourself and proceed as per the Docker Executor.

---

<div class="post-metadata">

**Author:** ![kevinwright](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/kevinwright/32/10618_2.png) [@kevinwright](https://discuss.circleci.com/u/kevinwright)\
**Post date:** [January 10, 2019, 8:42pm UTC](https://discuss.circleci.com/t/sbt-is-failing-with-outofmemory-in-recent-circleci-openjdk-8-images-when-building-a-docker-image-locally/27572/3 "2019-01-10T20:42:46Z")

</div>

This is fascinating… except… I’m not running in the executor.  
I’m simply running a docker build on my local machine using one of the images supplied by circleci

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [January 12, 2019, 1:41pm UTC](https://discuss.circleci.com/t/sbt-is-failing-with-outofmemory-in-recent-circleci-openjdk-8-images-when-building-a-docker-image-locally/27572/4 "2019-01-12T13:41:16Z")

</div>

Ah, righto - that puts a very different slant on it. In general, Docker will expand its memory to as much as it needs, limited either by specified limits or by memory available on the host. Since you do not have any limits set (in the build command), it might be that you do not have enough memory free to complete the operation.

Alternatively, perhaps there is a GC setting you can change. I would suggest searching Stack Overflow for the error (plus the word “Docker” maybe) to see how other folks have tackled it.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [April 12, 2019, 1:46pm UTC](https://discuss.circleci.com/t/sbt-is-failing-with-outofmemory-in-recent-circleci-openjdk-8-images-when-building-a-docker-image-locally/27572/5 "2019-04-12T13:46:01Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
