CDI UI Scope never cleaned up although UI detached?

I am trying to identify the source of a memory leak in a Vaadin 7 CDI application. The eclipse memory analyzer has revealed that the appliation’s UIs are never cleaned up, although they have long been
(days earlier according to the log files).

When looking at the GCRoot, it is always the “org.apache.deltaspike.core.util.context.ContextualInstanceInfo” that holds the reference.

Has anyone any idea what could prevent the release of the UI scope?

Used Versions:
Vaadin 7.7.6
CDI add-on 1.0.3
Delta Spike 1.5.3
Tomcat 8.0.41
Java 1.8.0_121

Is really no one using the CDI addon? Or am I the only one who experiences memory problems with it?


maybe this solves your problem.

But sadly they never pushed new Version for Vaadin 7, only for Vaadin 8.


Michael, thanks for your help. That was interesting, but my issue was a little different since the CDI UI and the last active CDI View were never cleaned up, even after session expiry.

The cause was a very simple mistake. But since others might also stumble into it, I want to share it:

At some point in the project, somebody introduced a custom servlet in order to add a BootstrapListener and configured it in the web.xml.
Unfortunately, this custom servlet was not derived from Vaadin
Servlet (which is used by default with CDI), but from VaadinServlet which - of course - does not care about cleaning up contextual resources…

A litle warning during startup would however have been very helpful (at least I haven’t seen one)…

Have you checked this issue report, does it match your case?

Jürgen, thanks a lot for sharing.

That was exactly what happened and extending from VaadinCDIServlet has fixed the problem.

High five !

Robson, that’s good to hear! High five!

It is good to note, in scope of original question, that in CDI add-on v1.0.5 there are fixes both regarding UI scope cleanup and issue regarding @PreDestroy.