Graal: SpringBoot classloaders initialization at build time leads to image heap polution

Created on 17 Apr 2020  路  1Comment  路  Source: oracle/graal

The native-image by default burns the set of classloaders: sun.misc.Launcher$ExtClassLoader, sun.misc.Launcher$AppClassLoader, ....
If ClassLoader.registerAsParallelCapable() is enabled, classloaders uses ClassLoader#parallelLockMap during parallel classes registration.
As a result, the ClassLoader#parallelLockMap contains several thousand of String->Object entries and all these entries from the map automatically burned into the image heap.

If Spring Boot classloaders (org.springframework.core.DecoratingClassLoader, org.springframework.context.support.ContextTypeMatchClassLoader,
org.springframework.core.OverridingClassLoader, ...) are initialized during the built time they perform ClassLoader.registerAsParallelCapable() calls and enables ClassLoader#parallelLockMap usage.
As a result, the image increases in a ~8-9Mb and also it can lead to an error during the image build (for example _"Static field or an object referenced from a static field changed during native image generation"_)

bug native-image spring

Most helpful comment

fixed with 9abecf764253a023c69882ca543848e3b4c9125e
Thanks @peter-hofer

>All comments

fixed with 9abecf764253a023c69882ca543848e3b4c9125e
Thanks @peter-hofer

Was this page helpful?
0 / 5 - 0 ratings

Related issues

helloguo picture helloguo  路  3Comments

himanshumps picture himanshumps  路  3Comments

sxend picture sxend  路  3Comments

janostgren picture janostgren  路  3Comments

borkdude picture borkdude  路  3Comments