Skip to content

UncaughtExceptionHandlerIntegration leaks memory #3266

Closed
@xenomote

Description

@xenomote

Integration

sentry

Java Version

17

Version

7.6.0

Steps to Reproduce

Cannot be very specific because sentry SDK is being used by a plugin within a framework, and within that environment we cannot reproduce the issue unless we are receiving production traffic

Expected Result

no memory leak

Actual Result

the UncaughtExceptionHandlerIntegration appears to occupy the majority of the heap, eventually resulting in memory exhaustion and a crash.

On auditing the code it appears that

final Thread.UncaughtExceptionHandler currentHandler =
threadAdapter.getDefaultUncaughtExceptionHandler();
if (currentHandler != null) {
this.options
.getLogger()
.log(
SentryLevel.DEBUG,
"default UncaughtExceptionHandler class='"
+ currentHandler.getClass().getName()
+ "'");
defaultExceptionHandler = currentHandler;
}
threadAdapter.setDefaultUncaughtExceptionHandler(this);

causes a stack to form, which prevents any of the exeption handlers from being GC'd and results in OOM. No idea why that register method is being called over and over again

image

we are planning to simply turn the UncaughtExceptionHandler off in the options to resolve this issue, but it's weird that the Sentry SDK apparently behaves this way by default

Metadata

Metadata

Assignees

Type

Projects

Status

Done

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions