Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparing with another JVMTI way to hook object allocation #38

Open
anonymouscode1 opened this issue Nov 30, 2020 · 2 comments
Open

Comparing with another JVMTI way to hook object allocation #38

anonymouscode1 opened this issue Nov 30, 2020 · 2 comments

Comments

@anonymouscode1
Copy link

Hello,

Since the JDK 11 already had a way to monitor object allocations (https://openjdk.java.net/jeps/331), what's the new feature the allocation-instrumenter can provide?

Thanks!

@jhmanson
Copy link
Contributor

Note that both this tool and JEP-331 came from the same team, and that this tool predates JEP-331 by about a decade. We developed that JEP because we couldn't do everything we wanted with this instrumenter.

That said, we find that this tool still has two meaningful use cases:

  • This lets you write the callbacks directly in Java without trampolining through native code. This is the biggest difference: many people don't want to deal with native code if they can avoid it, and it means developers can easily use Java logic their application already depends upon (e.g., logging) if they want. There's a performance penalty, but many folks are happy to take the tradeoff.

  • When instrumenting constructors, you can restrict which classes get instrumented, which allows a lightweight way of tracking instantiations of particular types.

@anonymouscode1
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants