john-chapman / im3d

Immediate mode rendering and 3d gizmos.
MIT License
1.18k stars 63 forks source link

memory leak #36

Closed YiMunDong closed 5 years ago

YiMunDong commented 5 years ago

I modified the code in the sample program (main.cpp).

include "im3d_example.h"

int main(int, char**) {

ifdef _DEBUG

_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);

endif

. . . A memory leak message was found in the result window.

Detected memory leaks! Dumping objects -> {4183} normal block at 0x00753568, 167 bytes long. Data: 68 35 75 00 00 00 00 00 00 00 00 00 00 00 00 00 {4182} normal block at 0x0BCB4FA8, 727 bytes long. Data: < O >; > > A8 4F CB 0B 3E 3B 17 3E 00 00 00 00 00 00 00 00 {4181} normal block at 0x0BC82148, 367 bytes long. Data: <H! &\= &\= > 48 21 C8 0B 94 26 5C 3D 94 26 5C 3D 00 00 00 00 {1376} normal block at 0x0BCCB108, 1807 bytes long. Data: < > 08 B1 CC 0B 00 00 20 C1 00 00 00 00 00 00 20 C1 Object dump complete.

john-chapman commented 5 years ago

Hi, thanks for reporting this. Did you also find memory leaks in another application using Im3d (not just the sample)?

YiMunDong commented 5 years ago

Yes, in other projects problems too.

If do nothing between "Im3d::NewFrame()" and "Im3d::EndFrame()", the problem does not occur. but, If insert one or more "Vertex" code, a leak occurs.

ex) Im3d::BeginPoints(); Im3d::Vertex(0, 0, 0, Im3d::Color_Red); Im3d::End();

john-chapman commented 5 years ago

Thanks again for reporting this. Indeed there was a leak in the Context destructor - some vectors were not properly destroyed. The issue is now fixed.