-
- extsmichalak
- Posts: 18
- Joined:
Assert while restarting Noesis (trying to init after shutdown)
Hey :)
We're wondering what's the reason behind not being able to restart Noesis, i.e.: trying to init once it was shut down? We're obviously hitting this assert:
Our use case would benefit from being able to restart it. Currently we have to keep it running, which is not necessarily memory-efficient.
We're using Noesis 3.1.0 (10745 revision)
Thanks,
Szymon
We're wondering what's the reason behind not being able to restart Noesis, i.e.: trying to init once it was shut down? We're obviously hitting this assert:
Code: Select all
NS_CHECK(gKernelState != KState::ShutdownInvoked, "Invoking Init after Shutdown not allowed");
We're using Noesis 3.1.0 (10745 revision)
Thanks,
Szymon
Re: Assert while restarting Noesis (trying to init after shutdown)
For historical reasons we don't support restarting Noesis because the reflection architecture is using internally local static variables. We have plans to revisit this with the new reflection system we are working on.
If you destroy all views, objects and resources, memory usage should be almost insignificant. Please, give us more detail about your scenario in a ticket if this is important for your project.
If you destroy all views, objects and resources, memory usage should be almost insignificant. Please, give us more detail about your scenario in a ticket if this is important for your project.
-
- extsmichalak
- Posts: 18
- Joined:
Re: Assert while restarting Noesis (trying to init after shutdown)
Thanks @jsantos, that's what we suspected. Is there any ETA on the new reflection system?
We need the ability to attach/detach our SDK, which contains Noesis - e.g. right now it fails to restart Noesis in our Unreal and Unity projects (inside the editor when we hit play and stop few times). That's why we keep Noesis running, while shutting down the rest of our stuff. In the future we might also need the ability to have several instances that we can freely init and shut down.
We need the ability to attach/detach our SDK, which contains Noesis - e.g. right now it fails to restart Noesis in our Unreal and Unity projects (inside the editor when we hit play and stop few times). That's why we keep Noesis running, while shutting down the rest of our stuff. In the future we might also need the ability to have several instances that we can freely init and shut down.
Re: Assert while restarting Noesis (trying to init after shutdown)
Not yet, as this is a risky step that will break client code we need to think carefully all the implications. But basically we are working in a less intrusive and more efficient reflection architecture. In this direction we are not sure if we should also remove Init and Shutdown functions as they will no longer make sense.Thanks @jsantos, that's what we suspected. Is there any ETA on the new reflection system?
Not calling Shutdown() doesn't mean Noesis is still running, you could even initialize Noesis at static time and perform Shutdown atexit time (a few clients are doing this AFAIK).We need the ability to attach/detach our SDK, which contains Noesis - e.g. right now it fails to restart Noesis in our Unreal and Unity projects (inside the editor when we hit play and stop few times). That's why we keep Noesis running, while shutting down the rest of our stuff. In the future we might also need the ability to have several instances that we can freely init and shut down.
You mean several instances of your SDK right? In this case, considering a global initialization of Noesis at static time makes more sense. We are doing something similar for our Unity plugin.In the future we might also need the ability to have several instances that we can freely init and shut down
-
- extsmichalak
- Posts: 18
- Joined:
Re: Assert while restarting Noesis (trying to init after shutdown)
Could you please elaborate? Not sure if I follow.Not calling Shutdown() doesn't mean Noesis is still running, you could even initialize Noesis at static time and perform Shutdown atexit time (a few clients are doing this AFAIK).
I just did a simple test and called `Noesis::GetAllocatedMemory()` before shutting down Noesis and after it:
Code: Select all
Before shutting down Noesis: 2646678 bytes, allocation count 159340
After shutting down Noesis: 0 bytes, allocation count 159390
Re: Assert while restarting Noesis (trying to init after shutdown)
Something like this:Could you please elaborate? Not sure if I follow.
Code: Select all
bool InitNoesis()
{
Gui::SetLogHandler(myLogHandler);
Gui::SetMemoryCallbacks(myMemoryCallbacks);
Gui::Noesis::Init();
#ifdef TRACK_MEMORY
atexit(Gui::Shutdown);
#endif
}
Yes, that's a lot. I was thinking on the hundreds of KB range, not MB. Could you please debug and tell me memories after each step at Shutdown?Unsure how bad `2646678 bytes` is, but doesn't seem to be insignificant as you mentioned earlier. Maybe we could do something more that `Noesis::Shutdown()` does, without shutting it down entirely?
Code: Select all
void Noesis::Shutdown()
{
if (gKernelState == KState::Initialized)
{
NS_LOG_INFO("Noesis Shutdown");
UnregisterPackages();
Boxing::Shutdown();
SymbolManager::Shutdown();
-
- extsmichalak
- Posts: 18
- Joined:
Re: Assert while restarting Noesis (trying to init after shutdown)
Hey @jsantos,
sorry it took me a while to get back to you, it wasn't trivial to get the actual values. Finally I got them:
Looks like unregistering the packages reduces the allocation by a lot. Is there anything we can do (call manually)?
sorry it took me a while to get back to you, it wasn't trivial to get the actual values. Finally I got them:
Code: Select all
void Noesis::Shutdown()
{
if (gKernelState == KState::Initialized)
{
NS_LOG_INFO("Noesis Shutdown");
// Memory allocation: 2 721 711 bytes
UnregisterPackages();
// Memory allocation: 417 177 bytes
Boxing::Shutdown();
// Memory allocation: 188 512 bytes
SymbolManager::Shutdown();
// Memory allocation: 0 bytes
}
}
Re: Assert while restarting Noesis (trying to init after shutdown)
I think that memory belongs to the global resources dictionary and more things we have in the UI module. Could you try setting to null everything you setup at init time from the IntegrationAPI header (SetApplicationResources, SetFontFallbacks, SetFontProvider, SetTextureProvider, etc).
Besides there is extra memory for the profiler, I assume this is a NS_PROFILE build right?
This probably needs a ticket to examine carefully.
Besides there is extra memory for the profiler, I assume this is a NS_PROFILE build right?
This probably needs a ticket to examine carefully.
-
- extsmichalak
- Posts: 18
- Joined:
Re: Assert while restarting Noesis (trying to init after shutdown)
We already set this to `nullptr`:
We also call `Reset()` for all of the `Noesis::Ptr` we use. We call `Noesis::UnregisterComponent` for all of the components, converters we register on init (btw. I verified that registering components does allocate memory, but unregistering doesn't clean it up).
Yes, it's a `NS_PROFILE` build.
Code: Select all
Noesis::GUI::SetApplicationResources(nullptr);
Noesis::GUI::SetSoftwareKeyboardCallback(nullptr, nullptr);
Noesis::GUI::SetTextureProvider(nullptr);
Noesis::GUI::SetXamlProvider(nullptr);
Noesis::GUI::SetFontProvider(nullptr);
Yes, it's a `NS_PROFILE` build.
Re: Assert while restarting Noesis (trying to init after shutdown)
It seems there are many things to improve and analyze here, please, create a ticket and let's continue the discussion there.
Who is online
Users browsing this forum: Ahrefs [Bot] and 3 guests