Why Method Breakpoints Slow Down Java Debugging and How to Fix It
This article explains how adding a method breakpoint in IntelliJ IDEA can increase Java application startup time by thousands of percent, explores the JVM and JPDA reasons behind the slowdown, and provides practical steps to remove or mitigate the performance impact.
Problem: Method Breakpoints Slow Debugging
When launching a project in IntelliJ IDEA in Debug mode, adding a method breakpoint can increase startup time from about 1.7 seconds to over 35 seconds, a 2000 % slowdown.
Investigation
The author reproduced the issue, compared runs with and without a method breakpoint, and traced the cause to the JVM’s handling of method breakpoints via JPDA’s Method Entry/Exit events.
Root Cause
Method breakpoints are implemented using JPDA’s Method Entry and Method Exit events, which fire for every thread entering or exiting any method, incurring high evaluation cost.
Official Guidance
Method breakpoints will slow down debugger a lot because of the JVM design, they are expensive to evaluate.
Solution: remove method breakpoints or use line breakpoints, and optionally disable the Method Exit event.
Practical Fixes
Delete method breakpoints from .idea/workspace.xml (method_breakpoints node).
In IDEA, right‑click a method breakpoint and uncheck “Method Exit”.
Disable collection rendering that invokes toString() during debugging.
Code Examples
Debugging a Stream pipeline:
class PrimeFinder {
public static void main(String[] args) {
IntStream.iterate(1, n -> n + 1)
.limit(100)
.filter(PrimeTest::isPrime)
.filter(value -> value > 50)
.forEach(System.out::println);
}
}
class PrimeTest {
static boolean isPrime(int candidate) {
return candidate == 91 ||
IntStream.rangeClosed(2, (int) Math.sqrt(candidate))
.noneMatch(n -> (candidate % n == 0));
}
}Debugging a concurrency issue:
public class ConcurrencyTest {
static final List<Integer> a = Collections.synchronizedList(new ArrayList<>());
public static void main(String[] args) throws Exception {
Thread t = new Thread(() -> addIfAbsent(17));
t.start();
addIfAbsent(17);
t.join();
System.out.println(a);
}
private static void addIfAbsent(int x) {
if (!a.contains(x)) {
a.add(x);
}
}
}Conclusion
Method breakpoints are a powerful but costly feature; use them only when necessary and consider disabling Method Exit events or switching to line breakpoints to avoid severe performance degradation.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Backend Technology
Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
