I am working on a rendering framework which has been progressing quite nicely. The framework is compiled into a static library. To test it I have made a different project that links the library files and creates some different scenes and such. Recently I decided that I wanted to be able to render Fbx meshes so I downloaded the Fbx SDK and created a new project where I played around with it to make sure I got the linking and functionality to work in a bare minimum setting. Now that I have got a working prototype I added it to my testing project (by linking the static library) and added the code. My project compiles fine, but I have run into a strange problem.
Seemingly if there is any usage of the Fbx SDK code in my code (no need to call/reach it, just that it is there) I get a bad alloc error from an unordered_map in my rendering framework (the unordered map is a static member of a class if that is in anyway relevant) once the first insertion into the map is attempted. If I remove the Fbx code (as in, don't use the code in the SDK, not that I actually remove the SDK from the project) then I do not get the bad alloc error. I assume I have done something whacky, but I have not found any evidence of what it could be. I have been using Visual Studio 2017 for all of the projects. All help is appreciated.
Edit: just discovered something weird, the problem only seem to appear in debug x64, not in release x64/x86 or in debug x86
Foo.h
class Foo
{
private:
static std::unordered_map<std::string, size_t> ids;
size_t myID;
public:
Foo();
Foo(const std::string& identifier);
...
};
Foo.cpp
std::unordered_map<std::string, size_t> Foo::ids;
Foo::Foo()
{
myID = 0;
}
Foo::Foo(const std::string& identifier)
{
auto target = ids.find(identifier);
if (target == ids.end())
{
myID = ids.size() + 1;
ids[identifier] = myID;
}
else
{
myID = ids[identifier];
}
}