Java process killed with no info as to why

I have a series of scripts that I run as a workflow job, and one of those scripts requires a jar to be executed, however CircleCI is for some reason killing the java task/process a few seconds into its execution.

The log tells me

./scripts/remap.sh: line 79: 377 Killed java -jar "$workdir/BuildData/bin/SpecialSource-2.jar" map -i "$jarpath.jar" -m "$classmappings" -o "$jarpath-cl.jar"

My config is currently:

# Java Maven CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-java/ for more details
#
version: 2
jobs: 
            
  # patch sources prior to compiling
  patch:
    docker:
      - image: circleci/openjdk:8-jdk
    steps:
      - checkout
      
      - run:
          name: Set Github Credentials
          command: |
            git config --global user.email "circleci@circleci.com"
            git config --global user.name "CircleCI"

      - run:
          name: Patch Sources
          command: ./scissors patch
        
  build:
    docker:
      - image: circleci/openjdk:8-jdk

    working_directory: ~/repo

    environment:
      # Customize the JVM maximum heap limit
      MAVEN_OPTS: "-Xmx3G"
      JAVA_OPTS: "-Xms3G -Xmx3G"

    
    steps:
      - checkout

      # Download and cache dependencies
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "pom.xml" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-

      - run: mvn dependency:go-offline

      - save_cache:
          paths:
            - ~/.m2
          key: v1-dependencies-{{ checksum "pom.xml" }}
        
      - run: mvn clean install

workflows:
  version: 2
  patch_and_build:
    jobs:
      - patch
      - build:
          requires:
            - patch

I’ve tried removing/adding the JAVA and MAVEN environment options,and nothing seems to make a different in my build.

Any information on why this process is being killed or how to fix it would be great. Thanks!

I suspect it isn’t CircleCI that is doing this - it is probably the Linux kernel in your build container. Given that this is Java, and you have a 4G RAM limit for the whole thing, I’d wager you’ve run out of memory.

Get an SSH session on your red build, and check dmesg to see if you get any “child sacrificed” messages. If you do, you may need to do more RAM tuning for Java. (Incidentally, you’ll find that using SSH will let you do an amend-test loop much more quickly anyway).

1 Like

Yea I’m getting a “child sacrificed” message and its saying something along the lines of out of memory.

Any way to add more memory to the container?

Managed to solve this- realized I did not specify _JAVA_OPTIONS as an environment variable for my patch job, the job which was failing. Xms and Xmx both set to 2G now and working fine.

Thank you

1 Like

Excellent! Yes, reducing memory consumption is nearly always the correct way to solve it. However, if you need to, you can pay for larger Docker containers. I think most people don’t need them.

1 Like

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