jkuhlmann / cgltf

:diamond_shape_with_a_dot_inside: Single-file glTF 2.0 loader and writer written in C99
MIT License
1.46k stars 136 forks source link

Possible memory leak with cgltf_data not cleaned up #113

Closed nihalkenkre closed 4 years ago

nihalkenkre commented 4 years ago

Hello.

I was using the Visual Studio 2019 Diagnostic Tools' Memory Usage tool on Windows 10.

After a bit of digging and prodding I ended up with this test, where I call a function to import a gltf and return. This is from the main function.

There are two breakpoints, 1 before the importing function is called and 2 after the function is called. Snapshots of the heap allocated are taken and it shows the following. I am interpreting this as the cgltf_data that was allocated is not being freed correctly.

Main function main_func

The which imports the gltf into a cgltf_data and frees the data. import_gltf_func

The snapshot of the heap at the breakpoint at the return statement. Ideally there should be no values here. snapshot

This is the call stack snapshot. snapshot_call_stack

Tried with imported 3 gltf files and the "count" parameter in the snapshot goes to 3.

Please let me know if you need more information, and if there is another way to verify this.

Best regards. Nihal Kenkre.

nihalkenkre commented 4 years ago

112 solves this.

Cheers!