I think that if you overload a placement new in the memory manager class, it will only be called when doing a placement new of a memory manager object.
Is that true even if they are declared globally? I know what you are saying is the case if the new operators are defined within a particular class, but these were defined global.
When I said they were defined in the memory manager class, that was a bit misleading. They are defined there (in the header for that class), but globally, not within the class. This is what it looks like:
#pragma once
#include "Hash.h"
namespace Enzyme
{
//some enums....
class MemoryManager
{
//all the class stuff...
};
extern "C" {DLLEXPORT extern MemoryManager MemoryMgr;}
//global overrides for new and delete operators
void* operator new(size_t size);
void* operator new[](size_t size);
void operator delete(void *p);
void operator delete[](void *p);
void* operator new(std::size_t size, const std::nothrow_t&);
void* operator new[](std::size_t size, const std::nothrow_t&);
void operator delete(void *p, const std::nothrow_t&);
void operator delete[](void *p, const std::nothrow_t&);
inline void* operator new(std::size_t, void *loc) {return loc;}
inline void* operator new[](std::size_t, void *loc) {return loc;}
inline void operator delete (void*, void*) { }
inline void operator delete[](void*, void*) { }
}
The first 8 seem to work fine, they are called from anywhere in the engine. The last 4, for whatever reason, are not (and I'm only assuming that's the case, the only one I've verified as actually not being called is the first of the 4, but I presume the others are not going to be called either).
I read something on the internets about how you cannot override a placement new operator. Is that possibly what is going on here?