apache / apache/netbeans

Using java debugger causes reproducible memory leak

Open
#9,262 3 comments 0 reactions 0 assignees View on GitHub
debugger Java kind:bug performance
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 29

### What happened

This is a very old (since NetBeans 8) and easily reproducible memory leak caused by simple debugging of java code. After debugging sessions instances of JPDADebuggerImpl remain registered in memory (owned by Swing related services), each owning large numbers of com.sun.tools.jdi.Packet instances.

### Language / Project Type / NetBeans Component

Java Ant prroject

### How to reproduce

* Open or create a java project (like NetBeans itself)
* Debug the project with the regular/internal debugger of NetBeans
* Stop debugging

![Image](https://github.com/user-attachments/assets/6f853d2c-7ec3-4e9f-b2c3-f89433b68baa)

![Image](https://github.com/user-attachments/assets/af395636-3767-48e7-990a-fc1549d516b7)

* Attach VisualVM, perform a GC and heamp dump
* Look for still visible instances of JPDADebuggerImpl

### Did this work correctly in an earlier version?

No / Don't know

### Operating System

Linux 6.12.74_1 x86_64

### JDK

OpenJDK 64-Bit Server VM (build 21.0.2+13-58, mixed mode, sharing)

### Apache NetBeans packaging

Apache NetBeans binary zip

### Anything else

This issue happens every time the debugger is used and renders NetBeans unusable after some debugging sessions because of low remaining memory. VisualVM-Heapdumps (.hprof) before/after debugging are available on request (100 - 200MB compressed).

### Are you willing to submit a pull request?

No

Contributor guide

Open the contributing guide

Research direction

Reproduce the leak by debugging a Java Ant project, stopping the session, and inspecting a GC heap dump with VisualVM. Start by tracing retained JPDADebuggerImpl instances and their com.sun.tools.jdi.Packet objects through the Swing-related services; done means debugger instances and packets are no longer retained after stopping.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.