Memory leak with JSF and view scoped beans in EAP 6

Solution Verified - Updated -

Issue

  • When a jsf action invalidate the current session and redirect to the current page, a referred view scoped managed bean leaks.
    SessionController:
public class SessionController {
    public void invalidateSession() throws Exception {
        ExternalContext externalContext= FacesContext.getCurrentInstance().getExternalContext();
        externalContext.getSessionMap().clear();
        HttpSession session = (HttpSession) externalContext.getSession(true);
        session.invalidate();
    }
}

LogoutController:

@RequestScoped
@ManagedBean
public class LogoutController {
    @Inject
    private SessionController sessionController;
    public String logout() throws Exception {
        sessionController.invalidateSession();
        // return to the start page
        return "/index.xhtml?faces-redirect=true";
    }
}

MyPageController:

@ViewScoped
@ManagedBean
public class MyPageController {
...
}

index.xhtml

...
<h:outputText value="Amount:"></h:outputText> <h:outputText value="#{myPageController.amount}" ></h:outputText>
...

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 6.3.3

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content