apache / apache/netbeans

Metaspace leak during indexing

Open
#8,702 1 comment 0 reactions 0 assignees View on GitHub
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 27 latest release candidate

### What happened

A smoke test which I run during each release which opens all ~800 NB modules and lets NB index them found a potential classloader leak. (but I don't think this is a regression)

Metaspace grows during indexing, closing projects or GC does not free it afterwards.

looks like this once all projects indexed:

Image

setting `-J-Djava.source.aptutils.disable.classloader.cache=true` does seem to help and GC appears to free resources again, but this might be only part of the story.

Image

### Language / Project Type / NetBeans Component

_No response_

### How to reproduce

```bash
set -e

# opens all netbeans modules as code scanner smoke test

# 1) build netbeans and change netbeans project JDK to "default"
# 2) run script in netbeans project

NB="/path/to/extracted/zip"
JDK="/home/mbien/dev/java/jdk-25-ea_b32"

OPEN=$(find -maxdepth 2 -mindepth 2 -type d\
-not -path "./.git*"\
-not -path "./nbbuild/*"\
-not -path "./dist/*"\
-not -path "./ide/xml.core"\
-not -path "./nbi/*" | sort | xargs)

#-J-Djava.source.aptutils.disable.classloader.cache=true

FLAGS="-J-Dorg.netbeans.modules.parsing.impl.indexing.LogContext\$EventType.PATH.treshold=20"

"$NB/bin/netbeans" --userdir /tmp/nbusr$$ --jdkhome $JDK $FLAGS $OPEN

```

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

No / Don't know

### Operating System

linux

### JDK

25

### Apache NetBeans packaging

Apache NetBeans binary zip

### Anything else

_No response_

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

Maybe but not soon

Contributor guide

Open the contributing guide

Research direction

Start by running the supplied smoke-test script against Apache NetBeans 27 on JDK 25, comparing metaspace and GC behavior with and without -J-Djava.source.aptutils.disable.classloader.cache=true. Trace the indexing path and the java.source.aptutils classloader cache to identify what remains referenced after indexing and project closure. Done means the leak is explained and metaspace is reclaimed without relying on the workaround.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.