Out of memory when flyway installs several migrations
When I start the application with an empty database,
Flyway can not execute all the migration because of Out of Memery
exception (09:42:06.188 [restartedMain] DEBUG
org.flywaydb.core.FlywayExecutor - Memory usage: 336 of 384M).
Instead, if some of the migrations are already istalled (approximately
half) before the start up, Flyway executes the missing migrations and
the application start correctly.
Analysing the heap dump of the OoM case I see that threre are a lot of istances of class org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver.
Why is memory occupancy lower when the migrations are installed in two runs?
Is it possible that Flyway accumulates memory space for each installed migration?
If so, is there any configuration to avoid it?
Thank you in advance.
Flyway Java API 9.5.1, Maven plugin 9.16.1, MySql 8.0
Comments
You can use the stream configuration to rectify this behavior
Stream would make it so that each statement is loaded individually instead of the entire migration in memory at once, so that should decrease the memory usage: https://documentation.red-gate.com/fd/stream-184127543.html
Kind regards
Dan Calver | Redgate Software
Have you visited our Help Center?