AZ-400 Practice Question: Design and implement build and release pipelines
You have a multi-stage YAML pipeline that builds and deploys a Java application. The pipeline runs on a Microsoft-hosted agent. The build stage fails intermittently with 'OutOfMemoryError: Java heap space'. What should you do to resolve this issue?
⚠ Common exam trap
Test-takers frequently confuse 'MAVEN_OPTS' with 'GRADLE_OPTS' or think that increasing agent memory (Option B) will automatically increase JVM heap, but the JVM heap is independent of physical memory and must be explicitly configured.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Set the environment variable 'MAVEN_OPTS' to '-Xmx2048m'.
The 'OutOfMemoryError: Java heap space' in a Maven build indicates that the JVM running Maven needs more heap memory. Setting the environment variable 'MAVEN_OPTS' to '-Xmx2048m' increases the maximum heap size for the Maven JVM process to 2048 MB, which resolves the memory issue. This is the standard and correct approach for Maven-based builds.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Set the environment variable 'MAVEN_OPTS' to '-Xmx2048m'.
Why this is correct
Setting MAVEN_OPTS to -Xmx2048m explicitly sets the maximum JVM heap size for the Maven process, ensuring the build has 2GB of heap available and directly addressing the OutOfMemoryError during compilation or tests. This is the standard environment variable for passing JVM arguments to Maven, and -Xmx is the primary switch to increase heap space.
- ✗
Use a self-hosted agent with more memory.
Why it's wrong here
While a self-hosted agent with more physical RAM might provide additional resources for the overall build environment, it does not directly address the OutOfMemoryError inside the Maven JVM. The Maven process's heap size is governed by the MAVEN_OPTS environment variable, not by the host's available memory. Even with ample free memory on the host, Maven's default heap allocation may still be too small, so the build can still fail unless you explicitly increase the maximum heap with -Xmx2048m in MAVEN_OPTS. Thus, scaling the agent is an indirect, less reliable workaround rather than the direct fix.
- ✗
Set the environment variable 'GRADLE_OPTS' to '-Xmx2048m'.
Why it's wrong here
GRADLE_OPTS is the environment variable that controls JVM arguments for Gradle builds, not Maven, so setting it would have no effect on a Maven pipeline's heap allocation. Since the pipeline uses Maven, the correct variable to modify is MAVEN_OPTS; using GRADLE_OPTS is a no-op that fails to resolve the memory error.
- ✗
Use the 'Maven@3' task with the 'jdkVersion' option set to 'jdk11'.
Why it's wrong here
Setting jdkVersion to jdk11 only selects the JDK version used by the Maven@3 task, which can affect bytecode compatibility and available JDK tools, but it does not change the JVM heap size. An out-of-memory error is caused by insufficient heap, not by the JDK version, so this option would not fix the problem; moreover, if the build already runs on JDK 11, this setting has no effect.
Visual reference
Go deeper
Related to this question
Learn chapter
Designing a Build Pipeline
Key term
YAML pipeline
A YAML pipeline is a text-based file written in YAML format that defines an automated series of steps for building, testing, and deploying software in a continuous integration and continuous delivery (CI/CD) system.
Key term
Environment
An environment is a dedicated set of computing resources, configurations, and services used to develop, test, or host software applications in a controlled and repeatable way.
About these practice questions
This AZ-400 question is part of Courseiva's 823-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This AZ-400 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-400 exam.