Vaadin portlet memory leak on handleRenderRequest

I have asked same question at Liferay forum (
But also want to duplicate it here.

I have made some test with Vaadin portlet which can be reinitialized on handleRenderRequest and faced some strange problem.
Here is code of the portlet:

public class Vaadin_load_portletApplication extends Application {
   Window mainWindow;
   public void init() {
     mainWindow = new Window("Vaadin_load_portlet Application");
     Label label = new Label("Hello Vaadin user");

    // set portlet listener, check if application is portlet and init user with listener
    if (getContext() instanceof PortletApplicationContext2) {
      PortletApplicationContext2 ctx = (PortletApplicationContext2) getContext();
      ctx.addPortletListener(this, new CustomListener());
    } else {
     getMainWindow().showNotification("Not inited via Portal!", Notification.TYPE_ERROR_MESSAGE);


  private class CustomListener implements PortletListener {

    /** The Constant serialVersionUID. */
    private static final long serialVersionUID = -6973370282667721257L;

    /** {@inheritDoc}  */
    public void handleRenderRequest(final RenderRequest request,
                                    final RenderResponse response,
                                    final Window window) {
      synchronized (this) {
        if (PortletMode.VIEW.equals(request.getPortletMode())) {

          System.out.println("removed all components");

          mainWindow.addComponent(new Label("test"));
          System.out.println("added label");


    /** {@inheritDoc}  */

    public void handleActionRequest(final ActionRequest request,
                                    final ActionResponse response,
                                    final Window window) {}

    /** {@inheritDoc}  */

    public void handleEventRequest(final EventRequest request,
                                   final EventResponse response,
                                   final Window window) {}

    /** {@inheritDoc}  */

    public void handleResourceRequest(final ResourceRequest request,
                                      final ResourceResponse response,
                                      final Window window) {


As you can see it is pretty simple, on each render request all component from mainWindow removed and new label text added.

I performed some load test of this portlet, which simply open page with portlet 4000 times (100 users with 40 repeated requests)

At the end of test I have analyzed heap dump I faced that instances of Label object is not collected with GC. I think this is not good since in case of lomg term portlet usage out of memory exception will be thrown.

I’m using vaadin 6.7.4 and liferay 6.1.1.

Also I folowed recomendation and upgrade vaadin to 6.8.10 but it didn’t helped.

How this can be avoided?