Skip to main content
InterviewHubPRO
Section Overview
Q50

Question 50 of 50

Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

100%
Apache Spark Big Data (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

Debugging Executor OOM: `Java heap space` vs `Container killed by YARN/K8s for exceeding memory limits`.

senior LevelMemory ManagementDocker & ContainersKubernetes

In Simple Words: Distinguishing the two distinct out-of-memory errors:

  1. java.lang.OutOfMemoryError: Java heap space:
    • Occurs inside the JVM.
    • Root Cause: Excessive memory allocations during large joins, aggregations, or huge arrays cached in memory.
    • Fix: Increase spark.executor.memory or increase shuffle partitions (spark.sql.shuffle.partitions) to reduce partition size.
  2. Container killed by YARN / K8s for exceeding memory limits:
    • The OS/Cgroup killed the executor container.
    • Root Cause: Off-heap memory exceeded allocated overhead (PySpark Python memory, native C-libraries, heavy off-heap shuffle buffers).
    • Fix: Increase spark.executor.memoryOverhead (e.g. from 10% to 25%).