So here's the deal: I've got a static character reference array which is an asset of a library I'm building. It's a global variable, and static so that it can only be accessed by the .cpp file containing the bulk of the library. The declaration/definition looks a bit like this:
Only it's over thirty thousand elements in size. So obviously I can't have it sticking around after the program using the library terminates. Unfortunately, I get a debug assertion error when I try to delete[] it. Is there some sort of special way to delete/free static globals, or is there something really obvious I'm missing?
I can't have it sticking around after the program using the library terminates.
The lifetime of data is bound to the process, not to the library. Even if the OS decided to let a dynamic library stay loaded after all the processes using it have terminated (which, to my knowledge, no OS does), it would only keep the code loaded. The data would still be freed because it belonged to the process.
I get a debug assertion error when I try to delete[] it
You can only use dynamic deallocation functions with dynamic data. Global arrays are static data.