imgui-node-editor
imgui-node-editor copied to clipboard
Memory leak
Both ASAN and Valgrind agree that there is a memory leak here:
==158445== 448 bytes in 1 blocks are definitely lost in loss record 2,581 of 2,616
==158445== at 0x483877F: malloc (vg_replace_malloc.c:307)
==158445== by 0x1AE4CB: MallocWrapper(unsigned long, void*) (imgui.cpp:1023)
==158445== by 0x1B51AA: ImGui::MemAlloc(unsigned long) (imgui.cpp:3608)
==158445== by 0x1D633D: ImVector<ImDrawCmd>::reserve(int) (imgui.h:1810)
==158445== by 0x1D5C17: ImVector<ImDrawCmd>::push_back(ImDrawCmd const&) (imgui.h:1813)
==158445== by 0x2256DF: ImDrawListSplitter_Grow(ImDrawList*, ImDrawListSplitter*, int) (imgui_node_editor.cpp:202)
==158445== by 0x225715: ImDrawList_ChannelsGrow(ImDrawList*, int) (imgui_node_editor.cpp:209)
==158445== by 0x2293E4: ax::NodeEditor::Detail::EditorContext::Begin(char const*, ImVec2 const&) (imgui_node_editor.cpp:1154)
==158445== by 0x21F582: ax::NodeEditor::Begin(char const*, ImVec2 const&) (imgui_node_editor_api.cpp:120)
I am creating a context for the editor and ensuring it's destructed when finished with the following code:
bool CMain::Initialize()
{
ed::Config cfg;
cfg.SettingsFile = nullptr;
m_context = ed::CreateEditor(&cfg);
return true;
}
CMain::~CMain()
{
if (m_context)
ed::DestroyEditor(m_context);
}
The render loop has nothing special
ed::SetCurrentEditor(m_context);
ed::Begin("Graph", ImVec2(0.0f, 0.0f));
// render stuff
ed::End();