What is the correct approach to "stop" or delete a render context?
In my Vue application, I am opening and closing vtk render windows. They do not seem to get garbage collected, since after 16 windows are opened, I get the following message:
WARNING: Too many active WebGL contexts. Oldest context will be lost.
This sounds like a memory leak issue.
How do I tell a render window to shut down and close its context, so it can be garbage collected properly?
What are you currently doing?
Ideally you want to unbind any listener you have set and delete the renderWindow.
Using the GenericRenderWindow which already handles creating and setting up the renderWindow object. There are no immediate functions that seem related to closing what it sets up.
I'm handling any additional camera related events I setup myself on closing.
Are you suggesting that for the given GenericRenderWindow instance I call .setRenderWindow(null)?
Do you do something along those lines?
beforeDestroy() {
this.view.setContainer(null);
this.view.delete();
}
I didn't see a .delete() in the documentation, but the documentation is just the source code, and it's hard to follow the module system's functions available to each component.
I will try that.
All instances in vtk.js are a vtkObject which have the following methods.
this.genericRenderWindow.setContainer(null);
this.genericRenderWindow.delete();
Did not work in the beforeDestroy() function
Indeed I see where the problem lies.
For now can you call
genericRW.setContainer(null);
genericRW.getOpenGLRenderWindow().delete();
genericRW.delete();
I would recommend putting in something to the generic window to handle that.
Yes the delete call should be fixed.
On Thu, Jul 25, 2019 at 6:43 PM Madison Dickson notifications@github.com
wrote:
I would recommend putting in something to the generic window to handle
that.—
You are receiving this because you commented.Reply to this email directly, view it on GitHub
https://github.com/Kitware/vtk-js/issues/1157?email_source=notifications&email_token=AACH45XLZ35GSEK2DGCA35DQBIT7VA5CNFSM4IGKVQZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD227JDQ#issuecomment-515241102,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AACH45UELC572QQSWXHM4VLQBIT7VANCNFSM4IGKVQZA
.
Confirmed that deleting the openGLRenderWindow fixed the issue.
How would you update the GenericRenderWindow's delete function to cascade delete internal dependencies?
inside the genericRenderWindow definition the following might work
publicAPI.delete = macro.chain(publicAPI.setContainer, model.openGLRenderWindow.delete, publicAPI.delete);
:tada: This issue has been resolved in version 11.1.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket: