I have a map that associates integers with vectors (of objects). These vectors are a set of tasks to perform. To reduce the amount of copy when using this map and vector, I set them to use pointers.
std::map<int, std::vector<MyObject *> *> myMap;
During the initialization of the class containing myMap, I populate myMap, creating a new vector populated with new MyObjects.
For me, though, it's memory management. Now I have these various objects sitting somewhere on the heap, and I am responsible for cleaning them when I am done with them. I also know that I will NEVER work with them until the program is completed. But after about 10 weeks, when someone decides that a smart way to change this application involves removing elements from the map / vectors. This will result in a memory leak.
My question is, how can I handle the proper release of these objects so that even if they were deleted using the STL function, what objects were deleted successfully?
Your help is much appreciated, let me know if I missed anything critical! Thanks!
Brian source
share