Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x.x] Prevent OutOfMemory on JDK 17 when loading EXPath Modules #4617

Merged

Conversation

ohumbel
Copy link
Contributor

@ohumbel ohumbel commented Nov 18, 2022

We use 4.x.x with custom org/exist/xquery/Functions.
This works fine on JDK 11.
As soon as we use JDK 17, we get OutOfMemory in the Non-heap region (Lambdas from org/exist/xquery/Function).
6 does not show the problem.

If we pick the commit:

4ec61b0
([bugfix] EXPath Repo classes must be instantiable via reflection, however LamdaMetafactory cannot cross classloader boundaries. As only EXPath Repo classes are now loaded by the EXistClassLoader everything else is loaded by a URLClassLoader (via AppAssemblerBooter), we have to use reflection instead of invokeDynamic to load EXPath Jar Modules)

from develop, the OutOfMemory goes away.

Forensics done together with @reinhapa.

…ever LamdaMetafactory cannot cross classloader boundaries. As only EXPath Repo classes are now loaded by the EXistClassLoader everything else is loaded by a URLClassLoader (via AppAssemblerBooter), we have to use reflection instead of invokeDynamic to load EXPath Jar Modules

Conflict manually resolved:
 exist-core/src/main/java/org/exist/xquery/XQueryContext.java
@adamretter
Copy link
Member

@ohumbel Thanks for the contribution, this is very interesting. Do you believe that this also occurs in eXist-db 5 and 6?

@adamretter adamretter changed the title [bugfix 4.x.x] Prevent OutOfMemory on JDK 17 [4.x.x] Prevent OutOfMemory on JDK 17 when loading EXPath Modules Nov 20, 2022
@ohumbel
Copy link
Contributor Author

ohumbel commented Nov 21, 2022

@ohumbel Thanks for the contribution, this is very interesting. Do you believe that this also occurs in eXist-db 5 and 6?

@adamretter We tested both eXist-db 4 and 6.
eXist-db 6 does not expose the problem.
On 4, the cherry pick of the one commit safely made OutOfMemory go away.
The commit gets rid of invokedynamic stuff like LambdaFactory and MethodHandles.
JDK 17 seems to handle these completely different.

If the commit already is on 5 (which I did not check), we could assume the problem is not there.

@adamretter
Copy link
Member

@ohumbel @reinhapa Ahhhh okay! I now understand that your fix is back-porting a commit from 5.x.x to 4.x.x

@adamretter adamretter merged commit 47ccec2 into eXist-db:develop-4.x.x Nov 21, 2022
@ohumbel ohumbel deleted the functionOutOfMemory branch November 24, 2022 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants