-
-
Notifications
You must be signed in to change notification settings - Fork 639
Description
Describe the issue
After calling "parseObj", lfpAlloc appears to leak memory. This seems to occur when vectors using lfpAlloc are resized, especially during emplace / push_back. This memory leak can be significantly large when loading hundreds of OBJ files.
By simply removing the "lfpAlloc" from all std::vectors used in tinyobj_loader_opt.h, I no longer leak memory.
To Reproduce
- repeatedly call parseObj.
- profile memory usage
- observe a collection of "lfpAlloc::Node<lfpAlloc::Chunk<<>>"'s that should be free'd once parseOBJ returns, but are not.
Please attach minimal and reproducible files(source codes, .obj/.mtl files, etc)
See @ogrex 's comment on issue #153. Repro can be done by modifying the "viewer.cc" file to repeatedly load a moderately large obj file.
Expected behavior
On return, parseOBJ should free all existing allocations to "lfpAlloc::Node<lfpAlloc::Chunk<<>>".
Alternatively, lfpAlloc should be removed as a dependency of tinyobj_loader_opt.h entirely, as this seems to fix the memory leak. I do not notice a significant impact on performance by removing lfpAlloc, however, more testing might be required to validate this is true.
Environment
- TinyObjLoader version: tinyobj_loader_opt.h on d2cb6d2
- OS: Windows 10
- Compiler: MSVC