Job randomly fails on Shared runner in Gitlab CI with exit code 137


We have a job in our pipeline that randomly fails with “Job failed: exit code 137”.
Our builds start from the following image: adoptopenjdk/maven-openjdk11:latest and our job simply executes Maven.
We use shared runners. This happens about half of the time. The other half it works without problems.
How can we debug this problem?