Thanks to visit codestin.com
Credit goes to GitHub.com

Skip to content

memory leaks on windows when using tinyobj_loader_opt.h #283

@natevm

Description

@natevm

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

  1. repeatedly call parseObj.
  2. profile memory usage
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions