c++ - Replacing existing raw pointers with smart pointers -
Note: this may look dumb. I have an application that uses raw pointers and there is a lot of memory leaks in the application.
Now my question is, how easy would it be to replace existing raw pointers with smart pointers and to help them deliver space, reducing memory leaks due to not being dynamically allocated memory free.
To explain a bit further, this application is a legacy and there are very clear memory leaks where memory will be allocated and will be used in the same function.
I have done a memory analysis using DevPartner and found in many areas. Wolgan is better than Deobaputra. Using Smart Pointers will definitely be a good start to clean your application, but they are not cures - all too many memory leaks may be negligent in another well-designed program, but more likely That you have important design problems and memory leaks is a symptom of that. When you switch to Smart Pointers, you will still need to make design options such as "Who is the owner of this object," "The ownership of this object is shared among many customers" and "the expected lifetime of this object What is "the proper Smart Pointer implementation for the given scenario but it would be a good way to start because the sm The process of choosing the appropriate taste of theert pointer will force you to think about these things and possibly improve your design.
Comments
Post a Comment