What k8s does when a java inside the pod throws OOM exception

1,475 views
Skip to first unread message

guillermo....@gmail.com

unread,
Jun 25, 2018, 5:44:11 PM6/25/18
to Kubernetes user discussion and Q&A
Does it mark the pod with OOMKilled?
I have a pod with memory limit 3GB and a java service that is set with -Xmx2g, so there is an extra GB for other container processes (there are not any significant).
So , is it possible that k8s marks the pod as OOMKilled when the java inside throws OutOfMemory?

Thanks.

Tim Hockin

unread,
Jun 25, 2018, 7:26:17 PM6/25/18
to Kubernetes user discussion and Q&A
No.  Kubernetes does not know anything about Java.

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.

Adam Kaplan

unread,
Jun 26, 2018, 8:10:31 AM6/26/18
to kubernet...@googlegroups.com
If the JVM throws an OutOfMemory error, then it means the JVM's heap ran out of space. Your pod may terminate with the "Error" status if Java is the primary process in the container, though this is not guaranteed (ex: if there are sidecar containers, or java is not PID 1 in the pod's container).

An OOMKilled could happen if you had -Xmx3g and the other processes lead to the container exceeding the resource restriction.
--

ADAM KAPLAN

SENIOR SOFTWARE ENGINEER - OPENSHIFT

Red Hat

100 E Davie St Raleigh, NC 27601 USA

adam....@redhat.com    T: +1-919-754-4843     IM: adambkaplan

guillermo....@gmail.com

unread,
Jun 26, 2018, 9:36:19 AM6/26/18
to Kubernetes user discussion and Q&A
Ok, thanks for your answers. So basically if the pod is OOMKilled and the java heap is set to 2GB, then there must be another reason, some other leaked resource. I am running a spring boot app with jdk 8. Is there a chance that it might be using memory that the heap allows?

Thanks again

guillermo....@gmail.com

unread,
Jun 26, 2018, 9:37:54 AM6/26/18
to Kubernetes user discussion and Q&A
...might be using MORE memory ...

Tim Hockin

unread,
Jun 26, 2018, 11:59:32 AM6/26/18
to Kubernetes user discussion and Q&A
Or it could be that the machine overall is over-committed and that was the process that was victimized.

shyam kishore alapati

unread,
Jun 26, 2018, 4:14:55 PM6/26/18
to kubernet...@googlegroups.com

I am using the same configuration on my cluster. I have other processes running in background on the container. I didn’t get out of memory errors, but whenever there was an error with the java process the status turned into "Error"

Thanks
Shyam

guillermo....@gmail.com

unread,
Jun 26, 2018, 4:54:12 PM6/26/18
to Kubernetes user discussion and Q&A

Thanks,

Is there a way to see the memory usage in the container (pod)? When I execute the top command inside the pod it seems to show the available memory of the node but not the specific pod. Am I doing something wrong? I need to understand who is using that extra Gb

Tim Hockin

unread,
Jun 26, 2018, 5:27:30 PM6/26/18
to Kubernetes user discussion and Q&A
Another source of difference could be per-CPU caches.  ISTR Java in particular as an offender.  It sees 16 cores on the machine and allocates 16 caches, even though you have only requested 4.0 cores through Kubernetes.

Federico Bongiovanni

unread,
Jun 26, 2018, 8:47:12 PM6/26/18
to kubernet...@googlegroups.com
Hi Guillermo, how are you running top inside the pod? kubectl top pod?

On Tue, Jun 26, 2018 at 1:54 PM <guillermo....@gmail.com> wrote:

Guillermo Coscarelli

unread,
Jun 27, 2018, 11:24:44 AM6/27/18
to kubernet...@googlegroups.com
I've tried with kubectl top (shows 2.7g each pod) but when logged into the pod and used linux's top shows that the java process is using only 1.7g, so I don't know who is using this extra GB, some kernel processes may be. Is it possible that the java is using resources outside the heap?

You received this message because you are subscribed to a topic in the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kubernetes-users/gJkW9l-h5CA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kubernetes-use...@googlegroups.com.

Federico Bongiovanni

unread,
Jun 27, 2018, 11:31:32 AM6/27/18
to kubernet...@googlegroups.com
I’m not sure I fully understand what you are doing, but java8 uses memory outside the heap for the metaspace, yes.

Federico Bongiovanni

unread,
Jun 27, 2018, 1:16:50 PM6/27/18
to kubernet...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages