Results 1 to 2 of 2

Thread: performance issues due to use of reflection API in dependency injection

  1. #1
    Join Date
    Dec 2010
    Posts
    1

    Default performance issues due to use of reflection API in dependency injection

    I am using Spring DI in domain objects using @Configurable and @Resource annotations. The rate of domain object creation is very high in my app. Since DI uses reflection, I have found that it results in high memory usage and high GC. I have confirmed this using java heap tool. This impacts the performance of the system and I am forced to change the design.

    I came across the suggestion provided in
    http://blog.springsource.com/2008/01...ction-feature/
    regarding the use of AbstractInterfaceDrivenDependencyInjectionAspect to bypass reflection.

    Kindly note that I have a large variety of such domain objects which are created frequently and it is not possible to specify all the attributes to be injected by Spring, in a configureBean() as the list varies.

    Has anyone faced similar performance issues. Is yes, kindly share any resolution ideas.

    I would appreciate your advice in this regard.

    Thanks
    RK7

  2. #2
    Join Date
    Jul 2010
    Location
    Venice, Italy
    Posts
    709

    Default

    use @Component on your beans and do component-scanning, then use @Autowired on public setter methods. This way, Spring won't need to use reflection to dependency inject beans into other beans.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •