Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory growth due to Marker object calling update function #578

Open
Naxior opened this issue Oct 28, 2022 · 1 comment
Open

Memory growth due to Marker object calling update function #578

Naxior opened this issue Oct 28, 2022 · 1 comment
Labels

Comments

@Naxior
Copy link

Naxior commented Oct 28, 2022

Description
When the Marker object calls the update function, the THREE.Mesh instance(color meterial) memory is not released.

  • Library Version: latest (develop branch)
  • ROS Version: Noetic
  • Platform / OS: Ubuntu 20.04

Steps To Reproduce

...
      case ROS3D.MARKER_TEXT_VIEW_FACING:
          this.traverse (function (child){
              if (child instanceof THREE.Mesh) {
                  child.material = colorMaterial;
              }
          });
          break;
      case ROS3D.MARKER_MESH_RESOURCE:
          var meshColorMaterial = null;
          if(message.color.r !== 0 || message.color.g !== 0 ||
             message.color.b !== 0 || message.color.a !== 0) {
              meshColorMaterial = this.colorMaterial;
          }
          this.traverse (function (child){
              if (child instanceof THREE.Mesh) {
                  child.material = meshColorMaterial;
              }
          });
          break;
...

Expected Behavior
Open Chrome developer tool and click Memory tag, memory stable

Actual Behavior
Memory is growing

Quick fix

...
      case ROS3D.MARKER_TEXT_VIEW_FACING:
          this.traverse (function (child){
              if (child instanceof THREE.Mesh) {
                  child.material.dispose();
                  child.material = colorMaterial;
              }
          });
          break;
      case ROS3D.MARKER_MESH_RESOURCE:
          var meshColorMaterial = null;
          if(message.color.r !== 0 || message.color.g !== 0 ||
             message.color.b !== 0 || message.color.a !== 0) {
              meshColorMaterial = this.colorMaterial;
          }
          this.traverse (function (child){
              if (child instanceof THREE.Mesh) {
                  if (child.material !== null) {
                      child.material.dispose();
                  }
                  child.material = meshColorMaterial;
              }
          });
          break;
...
@Naxior Naxior added the bug label Oct 28, 2022
@MatthijsBurgh
Copy link
Contributor

@Naxior I am not able to test it right now. But could you create a PR in the meantime? You found the bug, so it is better, when you write the commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants