TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
TIOBE - Java Coding Standard
Search

Rule:  Optimization100Checked automatically with code checker

Synopsis:Declare JAXBcontext variables as static.
Language:Java
Severity Level:3
Category:Optimization


Description:

In order to minimize PermGen memory usage, it is best to declare variables of type JAXBcontext as static. For example:

class MyServlet extends HttpServlet {
    static final JAXBContext context = initContext();

    private static JAXBContext initContext() {
        return JAXBContext.newInstance(Foo.class,Bar.class);
    }
}