1

I was reading some post around here about OutOfMemoryError: PermGen space. This one here took a special attention. Dealing with "java.lang.OutOfMemoryError: PermGen space" error

Also, this same post mentions other web references

As far as I understood the ClassLoader leak is, in some cases, associated with a deployment that have classes present inside the App ClassLoader which are beeing referenced from outside the App ClassLoader. The links in this posts illustrates an example, a Custom log Level.

Said that, my doubt is about Best Practice for Builds and Dependency Management. I use Maven and Bill of Materials with dependency analysis to check if I am not generate a package with more than I need. So far, so good. But I know that there is a precedence of Class Loader. In my case I use JBoss AS / WildFly that uses the UnifiedClassLoader.

In that case should I take in consideration that a WAR file built with Maven and BOM may have the same behavior as the example of the Logger? Is it still recommended to use BOM?

Community
  • 1
  • 1
  • There is no relationship with Maven itself or using a BOM it is more related with the implementation of the code you use in a app server (like using classloaders in your application which should always be avoided etc.)....or things like singletons in classical manner...better use CDI etc. for such things... – khmarbaise Jan 27 '16 at 12:18
  • When you mention "using classloaders in your application" you mean declarations like that inside the code that should be avoided to prevent Classloader leaks? Thread.currentThread().getContextClassLoader() or Thread.currentThread().getContextClassLoader().getResourceAsStream or Thread.currentThread().getContextClassLoader().getResource ? – Daniel Ferreira Castro Jan 27 '16 at 12:57
  • Thread.currentThread().getContextClassLoader().getResource... shouldn't be a problem..but what i'm asking myself about this is. Why do you need getContextClassLoader()... ? If it is a resource shouldn't getClass().getResources...() work as well? Reading of the classloader shouldn't be a problem but changing it with an app server...? – khmarbaise Jan 27 '16 at 13:38
  • I am not changing, just reading :) – Daniel Ferreira Castro Jan 27 '16 at 14:03
  • Ok..Than this is not problem..Some people to do some kind of thread handling them selfs (cause they believe they could do it better) within a app server which leads to issues with thread pools as well a permGemSpace problems...Ok... – khmarbaise Jan 28 '16 at 09:10

0 Answers0