sjoerd216
sjoerd216

Reputation: 1397

Severe memory leaks in the Autodesk Forge viewer on devices

I'm developing an Angular/ Typescript application that makes use of the Autodesk Forge viewer to display building models on smartphones and tablets. The application itself runs smoothly, but the problem occurs when I close the application. After closing the application, I notice that hardly any memory gets released, as can be seen in the image below (I close the application around the 8 seconds mark) and after opening the viewer for two or three more times it will run out of memory and crash. enter image description here When I close the application, I call both the tearDown() and the finish() method as described in the Forge docs and set all possible references to the Forge viewer to null, but they memory leak still persists. This is the main chunk of my viewer code:

this.initOptions = {
    path: 'url to model',
    env: 'Local',
    useADP: false,
    extensions: [],
};

Autodesk.Viewing.Initializer(this.initOptions, () => {

    this.onEnvInitialized();
});

private onEnvInitialized() {

    this.viewer = new Autodesk.Viewing.Private.GuiViewer3D(this.viewerContainer.nativeElement, {});
    this.viewer.initialize();
    this.viewer.loadModel(this.initOptions.path, {}, (doc) => {
        // further forge viewer execution here
    }, (errorMsg) => {
        console.log(errorMsg);
    });
}

public ngOnDestroy() {

    // remove all eventlisteners
    this.initOptions = null;
    this.viewer.tearDown();
    this.viewer.finish();
    this.viewer = null;
}

Is this a known issue and/ or is there some way I can manually release the memory used by the Forge viewer after closure? (It is part of the use case that I have to be able to open more than three viewers after each other in one session.)

Update [19-09-17]

I tried opening my viewer in a fresh, empty angular2 project, and although less memory is being used in general, the same behavoir of not clearing the memory still applies, as can be seen here. I do notice that the event listeners are drastically reduced now. I also updated the Forge Viewer to version 2.17, and the same issue still applies here as well.

Upvotes: 1

Views: 825

Answers (2)

Jaime Rosales
Jaime Rosales

Reputation: 1288

What version of the Viewer are you currently using? Here you can see a list of the recent changes on the viewer version, v2.17 has a Memory Limit ON by default.

https://developer.autodesk.com/en/docs/viewer/v2/overview/changelog/

Also the version of the viewer can be checked if it is not been defined from the console by typing LMV_VIEWER_VERSION

Upvotes: 0

Patrick Kersten
Patrick Kersten

Reputation: 21

The problem remains with version 3.3.5 of the forge viewer. The issue however seems a bit deeper. It looks like when calling viewer.finish() it doesn't release any GPU memory used for the textures.

We call this function everytime you navigate away from the page with the viewer as angular destroys the canvas in the DOM. I would expect .finish to also remove the textures from the memory. Is there any other function that can be called to completely unload any model and textures?

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

Upvotes: 0

Related Questions