We have static and global objects allocated on stack. These objects would be destroyed during process's main (…) function exit. But I would like to manage destruction of these before main's exit. To destroy these I will have to move the creation logic of these objects to heap and deallocate them. Is there any tool which tells us what all the static and global objects are still in the memory so that I can go ahead and make the code changes to destroy them.
Use case: There is a desktop application which uses static and global extensively. I would like to do little bit changes to this and use this as a library which should be stateless. For this during terminateLibrary all these static and global should be destroyed so that we can do subsequent InitLibrary afresh without actually restarting the process. moving existing architecture to totally a new design is very difficult and time taking, as there are huge number of these objects scattered through out the code. that's why I wanted to find out those static and global which is there in memory even after terminateLibrary called.