TomDmitriev / gradle-bundle-plugin

Apache License 2.0
47 stars 24 forks source link

OutOffMemory on large multi-module project #42

Closed xtracoder closed 8 years ago

xtracoder commented 8 years ago

Build fails on my production project with OutOfMemory (with -Xmx6g for example). Problems is caused by following:

and aQute's Builder holds really lot of temporary staff until the end of the whole multi-module build. In my case - the worst single module eats 370Mb. 10 such modules will consume 3.7GB оf memory.

This is caused by the way Gradle handles the build system - all tasks and their attributes (in that case tasks.jar.manifest) are kept alive until end of the build because they can be referenced from other (consecutive and dependent) projects.

I recommend restructuring the code in a way which does not store instance of aQute.bnd.osgi.Builder forever - i.e. use temporary instance only during actual invocation of builder.build() (see JarBuilder.build()).

For reference - screenshot from Eclipse MAT is attached. aqute-n-oom

TomDmitriev commented 8 years ago

@xtracoder, could you please grab 0.8-rc1 and verify that the problem has been resolved?

On 19 December 2015 at 15:23, xtracoder notifications@github.com wrote:

Build fails on my production project with OutOfMemory (with -Xmx6g for example) Problems is cause by following:

-

BundlePlugin replaces default jarmanifest with ManifestSubstitute

manifest = new ManifestSubstitute(jarBuilderFactory, manifest)

ManifestSubstitute internally holds reference on JarBuilderFactoryDecorator

it, in turn, holds reference on JarBuilder

it, in turn, holds reference on aQutebndosgiBuilder

and aQute's Builder holds really lot of temporary staff until the end of the whole multi-module build In my case - the worst single module eats 370Mb 10 such modules will consume 37GB оf memory

I recommend restructuring the code in a way which does not store instance of aQutebndosgiBuilder forever - ie use temporary instance only during actual invocation of builderbuild() (see JarBuilderbuild())

For reference - screenshot from Eclipse MAT is attached [image: aqute-n-oom] https://camo.githubusercontent.com/28ed8b3ff07e4d8e0651a8f8c68a9b7c4ffc7bb5/68747470733a2f2f636c6f756467697468756275736572636f6e74656e74636f6d2f6173736574732f323330313832302f31313931323933312f31333738643231342d613636342d313165352d396136662d636639623231336265376435706e67

— Reply to this email directly or view it on GitHub https://github.com/TomDmitriev/gradle-bundle-plugin/issues/42.

Yours sincerely, Artyom Dmitriev

xtracoder commented 8 years ago

Seems to be fixed.