Memory leak from undeleted Renderers
I have found that there is a memory leak from each clRenderer because they are created by "new" and stored by pointer in ms_Renderers, but are never deleted.
I have new code that fixes the issue when the Notebook goes out of scope, but I can't fork and PR because I get 403 forbidden accessing your repository.
Here are the changes I made.
- clTabRenderer.h :
public: static void DeleteRenderers(void) { for (auto& r : ms_Renderes) delete r.second; } - Notepad.cpp :
Notebook::~Notebook() { clTabRenderer::DeleteRenderers(); }
That's it. It works.
Thanks for the fix. I was facing the same issue but your fix did not work for me directly. I am using two instances of the Notebook. When the destructor is called for the first instance it works but then I got an access violation error when deleting the second one. My fix was:
- Setting the pointer to nullptr so that the following instances don't try to delete it again:
static void DeleteRenderers(void) { for (auto& r : ms_Renderes) { if (r.second) { delete r.second; r.second = nullptr; } } }
I'm assuming having more than 2 instances of the Notebook will also work but not tested. Thanks again :)