Question about the static object destruction when degign a memory allocator.

I want to implement a memory allocator but met a problem with the static object.
My memory allocator provide a global access interface. If there is a static object that use my memory allocator, for example a static std::vector which use a custom allocator.
After the main function, the static object's destruction is unordered. For my global memory allocator is also static, there is no way to make sure that my memory allocator is the last one to destruct.
So my program alway crush for the memory allocator is release but some static object still request to free its memory.
I think it is a common problem, almost every memory allocator will met this question, I wander how to resolve this?
Thank you.
Use new to dynamically allocate your allocator?
But when should I free the memory of my allocator?
When do you want to free it? If you previously allocated it statically, then it would live as long as the program, so you may as well use atexit() or maybe nothing at all if it's just memory.
I want to free it after all static object is destructed.
It seems atexit is the only way to resolve this.
Thank you.
Or, if you are using a modern OS that won't leak memory, don't bother freeing it at all.
Topic archived. No new replies allowed.