Jan
Topic Author
Posts: 5
Joined: 23 May 2017, 17:09

Cleaning up Noesis objects without calling Shutdown

03 Nov 2017, 15:14

Hi,

unfortunately we realized that we still have problems with the init and shutdown of Noesis (see my previous post: viewtopic.php?f=3&t=1162 - Noesis::GUI::Init failing after Noesis::GUI::Shutdown)

To help you understand our architecture: We are developing a plugin for CAD applications. When the user starts our rendering plugin, a new rendering thread is spawned. And when the rendering plugin is closed the rendering thread is terminated. If the user now reopens the rendering plugin a totally new thread is spawned. The process is never terminated, therefore we can't call Shutdown.

I thought the answer in my previous thread solved all of our issues (it solved at least the crash). But lately I realized that we have hundreds of those errors after starting, stopping and restarting Noesis:
Calling thread (9544) doesn't have access to this object (11840) - file: Gui\DependencySystem\Src\DispatcherObject.cpp:35
Funnily enough, everything still seems to work correctly without any issues. The first number is the thread id of our current rendering thread, the second number is the thread id of our previous rendering thread. Is it possible, that by not calling Noesis::GUI::Shutdown we have introduced a memory leak? There shouldn't be anymore object related to the old rendering thread. Is there a way to clean up the gui elements without calling Shutdown? I'm already calling Reset() on all of our object we've created with *new.

The cleanest solution would probably be to just spawn a new process instead of a new thread. But this would require more refactoring on our side which we can’t do right now.
 
User avatar
jsantos
Site Admin
Posts: 2900
Joined: 20 Jan 2012, 17:18
Contact:

Re: Cleaning up Noesis objects without calling Shutdown

06 Nov 2017, 18:34

Your usage of GUI::Init and GUI::Shutdown is correct. I don't think you are generating leaks that way. Please, make sure you are destroying the view and the tree each time a new thread is created. You must start from scratch each time you create a new render thread. The error you are getting is indicating that an object from the previous thread is being used in the current one.

There is also the possibility of having a bug in Noesis about this. We could be incorrectly caching internal objects that are created in the first render thread and later reused in subsequent threads. Could you please put breakpoints whenever you are getting those errors and observe the object that is generating it?

Who is online

Users browsing this forum: No registered users and 0 guests