Memory leaks in openNURBS?

Hi
We just started to use v7 and noticed that once we stop the program there a lot of leaks (at least there are reported as such). We tried to reproduce the issue with VS 20017 as follows:

  • latest version from github (branch 7.x)
  • opennurbs.h line 27 paste the following:
    #define _CRTDBG_MAP_ALLOC
    #include <stdlib.h>
    #include <crtdbg.h>
    #pragma warning( disable : 4996 )
  • opennurbs_dll.cpp line 37 paste:
    _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
  • opennurbs_public.h line 50 paste:
    #pragma warning( disable : 4996 )
  • opennurbs_public_examples.h line 23 uncomment #define OPENNURBS_IMPORTS, to use it as dll.

Build and run example_read without parameters than check VS output.

Detected memory leaks!
Dumping objects ->
{27412} normal block at 0x0000017AB98E54E0, 8976 bytes long.
Data: < > 00 00 01 00 01 00 00 00 04 00 00 00 00 00 00 00
e:\github\opennurbs\opennurbs_public_memory.cpp(65) : {23085} normal block at 0x0000017ABDDD39B0, 24 bytes long.
Data: < e n > 01 00 00 00 05 00 00 00 05 00 00 00 65 00 6E 00
e:\github\opennurbs\opennurbs_public_memory.cpp(65) : {23084} normal block at 0x0000017ABDD26400, 100 bytes long.


Object dump complete.
The program ‘[11368] example_read.exe’ has exited with code 0 (0x0).

It seems that all global variables declared in opennurbs_statics.cpp are reported as leaks. Hoverer, I believe they are false positives, but we should be sure about. Is there anybody who faced this issue?

Hi @akiss,

Statics allocate memory, sometimes as needed, which is eventually deleted. In some cases it is allocated once and then deleted when the app closes. But it is often deleted after Microsoft’s debug memory tracking tools stop tracking deletes.

In any case, one time allocation for global static objects is not leaking. We do understand that it makes it hard to find real leaks.

Hope this helps.

– Dale