Set up Master Memory

The Master is the controlling element of the Flink Cluster. It consists of three distinct components: Flink Resource Manager, Flink Dispatcher and one Flink JobManager per running Flink Job. This guide walks you through high level and fine-grained memory configurations for the Master.

The further described memory configuration is applicable starting with the release version 1.11. If you upgrade Flink from earlier versions, check the migration guide because many changes were introduced with the 1.11 release.

Note This memory setup guide is relevant only for the Master! The Master memory components have a similar but simpler structure compared to the TaskManagers’ memory configuration.

Configure Total Memory

The simplest way to set up the memory configuration is to configure the total memory for the process. If you run the Master process using local execution mode you do not need to configure memory options, they will have no effect.

Detailed configuration

The following table lists all memory components, depicted above, and references Flink configuration options which affect the size of the respective components:

  Component     Configuration options     Description  
Total Process Memory jobmanager.memory.process.size The total process memory size for the job manager. This includes all the memory that a job manager JVM process consumes, consisting of the total Flink memory, JVM metaspace and JVM overhead.
Total Flink Memory jobmanager.memory.flink.size The total Flink memory size for the job manager. This includes all the memory that a job manager consumes, except for JVM metaspace and JVM overhead. It consists of JVM Heap and Off-heap Memory Memory.
JVM Heap jobmanager.memory.heap.size JVM Heap memory size for job manager.
Off-heap Memory Off-heap memory size for job manager. This option covers all off-heap memory usage including direct and native memory allocation.
JVM metaspace jobmanager.memory.jvm-metaspace.size Metaspace size of the Flink JVM process
JVM Overhead jobmanager.memory.jvm-overhead.min
Native memory reserved for other JVM overhead: e.g. thread stacks, code cache, garbage collection space etc, it is a capped fractionated component of the total process memory

Configure JVM Heap

As mentioned before in the total memory description, another way to set up the memory for the Master is to specify explicitly the JVM Heap size (jobmanager.memory.heap.size). It gives more control over the available JVM Heap which is used by:

  • Flink framework (e.g. Job cache)
  • User code executed during job submission (e.g. for certain batch sources) or in checkpoint completion callbacks

The required size of JVM Heap is mostly driven by the number of running jobs, their structure, and requirements for the mentioned user code.

The Job cache resides in the JVM Heap. It can be configured by jobstore.cache-size which must be less than the configured or derived JVM Heap size.

Note If you have configured the JVM Heap explicitly, it is recommended to set neither total process memory nor total Flink memory. Otherwise, it may easily lead to memory configuration conflicts. The Flink scripts and CLI set the JVM Heap size via the JVM parameters -Xms and -Xmx when they start the Master process, see also JVM parameters.

Configure Off-heap Memory

The Off-heap memory component accounts for any type of JVM direct memory and native memory usage. Therefore, it is also set via the corresponding JVM argument: -XX:MaxDirectMemorySize, see also JVM parameters.

The size of this component can be configured by option. This option can be tuned e.g. if the Master process throws ‘OutOfMemoryError: Direct buffer memory’, see the troubleshooting guide for more information.

There can be the following possible sources of Off-heap memory consumption:

  • Flink framework dependencies (e.g. Akka network communication)
  • User code executed during job submission (e.g. for certain batch sources) or in checkpoint completion callbacks

Local Execution

If you run Flink locally (e.g. from your IDE) without creating a cluster, then the Master memory configuration options are ignored.