Skip to content

ArC: Cost of Instance.select() #22078

Answered by manovotn
famod asked this question in Q&A
Dec 9, 2021 · 2 comments · 4 replies
Discussion options

You must be logged in to vote

Hi @famod,

what beans are you resolving?

For normal scoped beans this isn't anyhow costly - it's a matter of few object allocations, resolution process (based on type and qualifier) and returning you a proxy. Although I should note that there is little reason to use Instance if you could just @Inject and store the beans you need in fields. While the resolution process isn't costly, it is still doing something which cannot compete with things like plain field access. Especially if you're going to do that repeatedly.

If it is @Dependent beans you are talking about, then this will make a huge difference as Instance will by default always create new contextual reference (i.e. new actual bean)…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@famod
Comment options

famod Dec 9, 2021
Collaborator Author

Comment options

You must be logged in to vote
3 replies
@famod
Comment options

famod Dec 9, 2021
Collaborator Author

@manovotn
Comment options

manovotn Dec 9, 2021
Collaborator

@famod
Comment options

famod Dec 9, 2021
Collaborator Author

Answer selected by famod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
area/arc Issue related to ARC (dependency injection)
2 participants