johnzon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Kay (Jira)" <>
Subject [jira] [Commented] (JOHNZON-161) JohnzonCDIExtension might create a mem leak
Date Tue, 21 Apr 2020 22:30:00 GMT


Stephen Kay commented on JOHNZON-161:

We get this issue with Johnzon 1.1.13 - shipped with TomEE 8.0.1.

The full story :

We did a migration from Jackson to Yasson / for the JsonB reference implementation.

Our code was based on JsonB specs and uses (a lot) JsonBuilder.create() - but without try-with-references. 

With all these Jsonb instances, No problem with Yasson - the Jsonb objects were GC correctly.


Riding TomEE we use Johnzon. And now, the references keep fixed in memory and we observe the
memory leak.


Now we corrected surrounding all JsonBuilder.create() with try-with-references

But this sounds very artificial comparing to previous code - as other implementations don't
require this noisy wrap.

This is likely prone to create new memory leak issues at any future changes pushed by developers
not aware of this problem.


Had this issue any workaround / or resolved in an other ticket? 

Do you have any suggestions for resolving this problem?

How can we get a JsonB instance with CDI linked to the current thread, with some given config?

Best Regards

> JohnzonCDIExtension might create a mem leak
> -------------------------------------------
>                 Key: JOHNZON-161
>                 URL:
>             Project: Johnzon
>          Issue Type: Task
>          Components: JSON-B
>    Affects Versions: 1.1.7
>            Reporter: Mark Struberg
>            Priority: Major
>             Fix For: 1.2.5
> We use Json-B quite heavily and I experienced that there are tons of elements in org.apache.johnzon.jsonb.cdi.JohnzonCdiExtension#jsonbs.
> Way too much for my gut feeling.
> The reason is that we do not use JsonBuilder as autocloseable is that it is not required
by the spec.
> There is also not much documentation for JohnzonCdiExtension, so I can only guess that
it is for cleanly shutting down unused JsonbBuilder instances when the app stops.
> We should probably only store WeakReferences.
> I think the safest

This message was sent by Atlassian Jira

View raw message