Skip to content

Commit

Permalink
Use DB_CLOSE_ON_EXIT=FALSE for H2 DevServices
Browse files Browse the repository at this point in the history
To avoid metaspace leaks when H2 registers one shutdown hook each
time we start it: the shutdown hook indirectly references a
QuarkusClassLoader of its corresponding application startup,
which references loads of Quarkus and application classes and
prevents them from being garbage collected, which ultimately leads to
OutOfMemoryError: Metaspace.

This impacts devmode in particular.
  • Loading branch information
yrodiere committed Oct 18, 2023
1 parent be3b93b commit 2e5414a
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public RunningDevServicesDatasource startDatabase(Optional<String> username, Opt

String connectionUrl = "jdbc:h2:tcp://localhost:" + tcpServer.getPort() + "/mem:"
+ effectiveDbName
+ ";DB_CLOSE_DELAY=-1" + additionalArgs.toString();
+ ";DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + additionalArgs;
return new RunningDevServicesDatasource(null,
connectionUrl,
null,
Expand Down

0 comments on commit 2e5414a

Please sign in to comment.