GithubHelp home page GithubHelp logo

Possible leak using Guice about guice HOT 5 CLOSED

lucianoRM avatar lucianoRM commented on May 28, 2024
Possible leak using Guice

from guice.

Comments (5)

mcculls avatar mcculls commented on May 28, 2024

The generated glue held inside that ClassValue should be unloaded when the host class (ie. the application class) is unloaded, which is when its class-loader is able to be unloaded. I can double-check with a simple test app, but it sounds like something else is keeping your child class-loaders alive, which then keeps those generated fast-classes alive.

Is your code publicly available?

Note if you don't need bytecode generation then you can turn it off with:

-Dguice_bytecode_gen_option=DISABLED

but that would also mean you couldn't do method interception.

from guice.

lucianoRM avatar lucianoRM commented on May 28, 2024

Sorry, the code is not public.

The only strong references I am seeing are from Guice. But, maybe once the weak/soft references are cleaned, since Guice's references will be the only ones, they will be cleaned as well? I could check that.

In which scenario would we be using method interception?

We only have a bunch of Modules either binding Interfaces to Implementations (in the configure() method) or defining a @ Provides method.

As for injection, we do field and constructor injection with @ Inject

from guice.

mcculls avatar mcculls commented on May 28, 2024

Part of the problem with unloading is that a lot is held back until the class-loader itself becomes unloadable, which does make it hard to debug - we do have tests in the codebase to verify proxy unloading, which uses a similar mechanism, and those are currently passing.

Regarding method interception - that's if you are using the bindInterceptor method: https://github.com/google/guice/wiki/AOP

If you're not using that then try adding -Dguice_bytecode_gen_option=DISABLED as a JVM option to see if it helps.

from guice.

lucianoRM avatar lucianoRM commented on May 28, 2024

Awesome! I will try to figure out if there is anything else preventing the Class Loader to be unloaded.

In the meantime, I will try using that flag, I don't think I require method interception. Maybe I can isolate the root problem better.

Thanks for the quick response!

from guice.

lucianoRM avatar lucianoRM commented on May 28, 2024

Following up on this

Using -Dguice_bytecode_gen_option=DISABLED definitely worked. I no longer see those paths to GC roots. What's more, the service seems to be working just fine, so I guess we can execute without method interception.

However, based on the information you provided, even if using bytecode generation, those paths should be cleared. So, I will keep searching for another cause for this issue. I already have a lead with a lib we are using.

Closing this ticket for now.

Thanks a lot for the help!

from guice.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.