isl-org / isl-org/Open3D

Memory Leak when add mesh to scene

Open
#5,352 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
14k
Forks
2.6k
Avg merge
5d 18h
Merged PRs (30d)
6

Description

### Checklist

- [X] I have searched for [similar issues](https://github.com/isl-org/Open3D/issues).
- [X] For Python issues, I have tested with the [latest development wheel](http://www.open3d.org/docs/latest/getting_started.html#development-version-pip).
- [X] I have checked the [release documentation](http://www.open3d.org/docs/release/) and the [latest documentation](http://www.open3d.org/docs/latest/) (for `master` branch).

### Describe the issue

The memory usage constantly increases when a add a model, clear geometry, and re-add a new model to the OffscreenRenderer scene. Even if I recreate the OffscreenRenderer instance at each iteration, at a certain point, the memory leak starts again
I appreciate any help.

### Steps to reproduce the bug

```python
import open3d as o3d
import csv

# main entry point
def main():

input_files = read_list_gltf('./list.csv')

render = o3d.visualization.rendering.OffscreenRenderer(512, 512)
render.scene.set_background([0.1, 0.2, 0.3, 1.0]) # RGBA
render.scene.show_axes(True)
vertical_field_of_view = 15.0 # between 5 and 90 degrees
aspect_ratio = 1 # azimuth over elevation
near_plane = 0.1
far_plane = 50.0
fov_type = o3d.visualization.rendering.Camera.FovType.Vertical
render.scene.camera.set_projection(vertical_field_of_view, aspect_ratio, near_plane, far_plane, fov_type)

# Look at the origin from the front (along the -Z direction, into the screen), with Y as Up.
center = [0, 0, 0] # look_at target
eye = [0, 0, 10] # camera position
up = [0, 1, 0] # camera orientation
render.scene.camera.look_at(center, eye, up)

for model_index, file in enumerate(input_files):

model = o3d.io.read_triangle_model(file)
render.scene.add_model(f'model', model)

# render to image code
# ....

# clear scene
render.scene.clear_geometry()
model = None
```

### Error message

_No response_

### Expected behavior

The update of the scene should not cause a memory leak.

### Open3D, Python and System information

```markdown
- Operating system: Windows 11 64-bit
- Python version: 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)]
- Open3D version: 0.15.1
- System architecture: x86
- Is this a remote workstation?: no
- How did you install Open3D?: pip
- Compiler version (if built from source): NA
```

### Additional information

Memory usage after a few seconds
![capture-20220723-249](https://user-images.githubusercontent.com/40924356/180619119-5516e19e-9e09-49f0-bc0b-af6387902377.png)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.