Closed Logabe closed 3 months ago
Do you keep references to these objects? To me this sounds like you are creating objects that you don't retain a reference to.
Yes, I keep the objects stored in the main Window class. They still draw every frame.
Then without seeing some of your code I can't really say anything. My code should not be able to invoke the dispose method of your objects.
I've uploaded an archive containing the project - I wasn't sure what was important or not, but it isn't massive since this is still very much a testing project. I hope this can help. Project.zip Again, there's a good change that it's entirely my fault, but I couldn't find any reason why that would be. Thanks again, Logabe
MainState.cs
:
Model.cs
:
Here you are creating objects in the constructor of the object that you then override. This means that the original objects you create are going to be garbage collected without having been disposed, causing the printout. The reason this didn't happen before is likely because the code before never did anything that triggered a garbage collection.
The solution is to not allocate objects in the constructor and only do it in OnEnter
.
I'm not entirely sure if this issue is my problem or your code's problem, but I'm putting it here in the hope that I can get some explanation of what's going on. I've been following the LearnOpenTK Tutorial up to tutorial 1.3 (Index buffers), and I've written helper classes to wrap around the concept of a mesh and shader. These classes implement
IDisposable
, but have destructors that will warn if the object hasn't properly been disposed yet. Before using the ImGuiController, there weren't any problems. After integrating the controller based off of theWindow.cs
file seems to be calling the destructors. For some strange reason, puttingcontroller.Update(this, (float)e.Time);
as used in the example program will cause the destructor to be called once on:Mesh 1
I can still use the objects and nothing seems to have been deleted, but it's a bit weird to see and makes it hard to tell what are actual mistakes on my end. Thanks, Logabe