essobedo commented on PR #9266:
URL: https://github.com/apache/camel/pull/9266#issuecomment-1409967882

   > > Some remarks. Could you explain what is the benefit of converting the 
classes into static inner classes?
   > 
   > It avoids having a reference to the enclosing class, thus saving a (small) 
amount of memory and making things easier for the garbage collector.
   > 
   > From the Effective Java:
   > 
   > _"... If you declare a member class that does not require access to an 
enclosing instance, always put the static modifier in its declaration, making 
it a static rather than a nonstatic member class. If you omit this modifier, 
each instance will have a hidden extraneous reference to its enclosing instance 
... "_
   > 
   > _"... As previously mentioned, storing this reference takes time and 
space. More seriously, it can result in the enclosing instance being retained 
when it would otherwise be eligible for garbage collection (Item 7). The 
resulting memory leak can be catastrophic ..."_
   > 
   > Given that our core tests are failing due to OOM, it's a small thing that 
helps.
   
   I see even if I really doubt that it will change anything as they are mostly 
`RoutesBuilder` so their references are still held somehow by the 
`CamelContext`.
   
   Anyway, if so you should have used another commit message something like 
"Avoid references to enclosing instance" instead of "tests cleanup".
   
   Regarding the OOM issue, is there any ticket for this?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to