Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Memory Leak in ListGrid.

    Hi,

    I expect that an event is never destroyed.

    In Canvas.js this event is destroyed:
    Code:
      this._resizeID = isc.Page.setEvent(this._$resize, this, isc.Page.FIRE_ONCE);
    in EventHandler.js :
    Code:
      canvasDestroyed : function (canvas) {
          ....    
          if (canvas._resizeID) isc.Page.clearEvent(canvas._$resize, canvas._resizeID);        
          ...
    But in Canvas.js, this event is never destroyed:
    Code:
            isc.Page.setEvent(
                "resize",
                this,
                isc.Page.FIRE_ONCE,
                "_relativePageResized"
            );
    So, the ListGrid remain attached thanks to _eventRegistry


    Sample Code:
    Code:
        private ListGrid lg = null;
    
        public static ListGridRecord createRecord(String name, String surname) {
            ListGridRecord record = new ListGridRecord();
            record.setAttribute("Name", name);
            record.setAttribute("Surname", surname);
            return record;
        }
    
        public static ListGridRecord[] getRecords() {
            return new ListGridRecord[] {
                    createRecord("Name1", "Surname1"),
                    createRecord("Name2", "Surname2"),
                    createRecord("Name3", "Surname3")
            };
        }
    
        private ListGrid getListGrid() {
            final ListGrid grid = new ListGrid();
    
            grid.setWidth(500);
            grid.setHeight(300);
            grid.setData(getRecords());
    
            ListGridField nameField = new ListGridField("Name", "Name", 50);
            nameField.setCanEdit(true);
            ListGridField surnameField = new ListGridField("Surname", "Surname");
            surnameField.setCanEdit(true);
    
            grid.setFields(nameField, surnameField);
            return grid;
        }
    
        @Override
        public void onModuleLoad() {
            final com.google.gwt.user.client.ui.VerticalPanel sp = new com.google.gwt.user.client.ui.VerticalPanel();
            sp.setSize("100%", "100%");
            com.google.gwt.user.client.ui.Button btn = new com.google.gwt.user.client.ui.Button("TEST");
            sp.add(btn);
    
            btn.addClickHandler(new ClickHandler() {
    
                @Override
                public void onClick(ClickEvent event) {
                    sp.remove(lg);
                    lg.destroy();
                    lg = getListGrid();
                    sp.add(lg);
                }
            });
    
            lg = getListGrid();
            sp.add(lg);
            RootPanel.get().add(sp);
        }
    Each time you click on the button, you create a leak.


    Leak in google DevTools:

    Click image for larger version

Name:	leak.JPG
Views:	138
Size:	46.6 KB
ID:	258786

    Is-it a smartGwt Bug or shall i call a function to free _eventRegistry?

    Thanks for your help.

    Mike.

    #2
    When you report a problem, you need to include the exact version of SmartGWT that you're using, as per the FAQ.. An example of an exact version is "v12.0p_2019-07-22/EVAL Deployment".

    Comment


      #3
      Sorry , i use version: v12.0p_2019-07-22

      Comment


        #4
        We've committed a fix for this issue to SGWT/SC 12.0 and newer releases, which should be in today's nightly builds. (If there's no build today for a branch, it will be in the next nightly that is published.)

        Note that the specific issue you reported only applied to relatively positioned components, which is an approach we recommend only for legacy situations. Furthermore, with respect to page "resize" event handlers in general, it's unlikely that the leak would cause an issue in the real world, as the stale handlers would have gotten removed the first time the browser got resized by the user.

        Comment


          #5
          Hi Isomorphic,
          Thank you for the fix.
          It's really better in today's version.

          FYI, we currently use gxt framework. The smartgwt grid is better (for out usage) so we replace the gxt grid by the smartgwt grid in our application. We can't quickly replace all gxt components by smartgwt components. It's probably what you call a legacy solution.

          Again, thank you for the fix

          Comment

          Working...
          X