Skip to content

Memory growth due to MarkerArrayClient processMessage(arrayMessage) function #630

Description

@shyl886

Description
When I call ROS3D.MarkerArrayClient in my web, I see the web memory is increasing until crashing from Task Manager

  • Library Version: latest (develop branch)
  • ROS Version: melodic
  • Platform / OS: Ubuntu 18.04

Steps To Reproduce

function init() {
    // Create the main viewer.
    var viewer = new ROS3D.Viewer({
        divID: 'radar_markers',
        background: '#707070',
        width: 650,
        height: 650,
        antialias: true,
        displayPanAndZoomFrame: false
    });

    // Setup a client to listen to TFs.
    var tfClient = new ROSLIB.TFClient({
        ros: ros,
        angularThres: 0.01,
        transThres: 0.01,
        rate: 100.0,
        fixedFrame: '/rslidar'
    });

    var gridClient = new ROS3D.Grid({
        num_cells: 20
    });
    var axesClient = new ROS3D.Axes({
    });

    viewer.addObject(gridClient);
    viewer.addObject(axesClient);

    var markerArrayClient1 = new ROS3D.MarkerArrayClient({
        ros: ros,
        tfClient: tfClient,
        topic: '/vis_s1_objects',
        rootObject: viewer.scene
    });

    var markerArrayClient2 = new ROS3D.MarkerArrayClient({
        ros: ros,
        tfClient: tfClient,
        topic: '/vis_s2_objects',
        rootObject: viewer.scene
    });
    var markerArrayClient3 = new ROS3D.MarkerArrayClient({
        ros: ros,
        tfClient: tfClient,
        topic: '/vis_s3_objects',
        rootObject: viewer.scene
    });
}

Expected Behavior
Open Chrome web, the memory is stable

Actual Behavior
Memory is growing fast until crashing in several minutes

My Action
In below ros3djs MarkerArrayClient class processMessage(arrayMessage) function, when I remove " this.rootObject.add(this.markers[key]); " , the web memory will become stable, so I guess maybe here will be the issue, does anybody know how to fix?

processMessage(arrayMessage) {
  arrayMessage.markers.forEach(function(message) {
      var key = message.ns + message.id;
      if (message.action === 0) {
          var updated = false;
          if (key in this.markers) { // "MODIFY"
              updated = this.markers[key].children[0].update(message);
              if (!updated) { // "REMOVE"
                  this.removeMarker(key);
              }
          }
          if (!updated) { // "ADD"
              var newMarker = new Marker({
                  message: message,
                  path: this.path,
              });
              this.markers[key] = new SceneNode({
                  frameID: message.header.frame_id,
                  tfClient: this.tfClient,
                  object: newMarker
              });
              this.rootObject.add(this.markers[key]);
          }
      } else if (message.action === 1) { // "DEPRECATED"
          console.warn('Received marker message with deprecated action identifier "1"');
      } else if (message.action === 2) { // "DELETE"
          this.removeMarker(key);
      } else if (message.action === 3) { // "DELETE ALL"
          for (var m in this.markers) {
              this.removeMarker(m);
          }
          this.markers = {};
      } else {
          console.warn('Received marker message with unknown action identifier "' + message.action + '"');
      }
  }.bind(this));

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions