Patrick Kersten
Patrick Kersten

Reputation: 21

Autodesk Viewer memory leak

I have some big memory issues in an angular/typescript app using the forge viewer (v6.6.1). This has also been discussed before: Severe memory leaks in the Autodesk Forge viewer on devices

Whenever we close the component or route to an other page we destroy the current created viewer. For this I use the function viewer.finish(); However it seems that it doesn't release any GPU memory. This is most notable when using models that contain textures. The problem is that after a few times opening this in our app it will crash as to much gpu memory is used.

To see the memory usage buildup I used chrome://tracing/ (using the record category memory-infra).

Here are some screenshots where you can see the memory buildup.

Initial initialisation of the page

after returning to this page after closing it

after returning to this page after closing it a third time

As you can see the memory under textures builds up quite fast. And this is just a light model that we use. With some models is build up in steps of over 250MB.

Here is the part of component code that does the work. I also provided a link to a minimal angular project on github that you can run. When you start the app you can use the toggle button to create / destroy the component and trigger the issue.

  public viewer;
  public options;
  public url = 'MODEL-YOUR-URL-HERE';

  @ViewChild('viewer')
  public viewerContainer: any;

  constructor() { }

 ngOnInit() {
    this.options = {
      env: 'Local',
      useADP: false,
      language: 'en',
    };

    Autodesk.Viewing.Initializer(this.options, () => {
      this.onEnvInitialized();
    });
  }


  public onEnvInitialized() {
    this.viewer = new Autodesk.Viewing.Private.GuiViewer3D(this.viewerContainer.nativeElement, {});
    this.viewer.initialize();
    this.viewer.loadModel( decodeURI(this.url), {}, () => { }, (aErrorCode) => { } );
  }

  ngOnDestroy() {
    this.viewer.finish();
    this.viewer = null;
  }

https://github.com/zedero/forge-angular-memory-issue

Upvotes: 0

Views: 434

Answers (1)

Bryan Huang
Bryan Huang

Reputation: 5342

Engineering's final recommendations are to wait for Viewer v7.0 which is set to release for general access in a few weeks time with multiple bug fixes & improvements on memory management.

In the meantime see if you have any event listeners/custom extensions that might be holding on to references to nodes etc - remove/unload these and see if that helps.

Upvotes: 0

Related Questions