Are all objects (Database connections, Sockets, Files, etc.) freed even when an error occurs?
File, Sockets, Database connections, etc. (basically all objects where a creation and a deletion method exist) should be freed even when an error occurs. For example, whenever you use “new” in C++, there should be a delete somewhere that disposes of the object. Resources that are opened must be closed. For example, when opening a file in most development environments, you need to call a method to close the file when you’re done. Is the same object released more than once? Make sure there’s no code path where the same object is released more than once. Check error code paths. Does the code accurately keep track of reference counting? Frequently a reference counter is used to keep the reference count on objects (For example, COM objects). The object uses the reference counter to determine when to destroy itself. In most cases, the developer uses methods to increment or decrement the reference count. Make sure the reference count reflects the number of times an object is referred.
Related Questions
- How to resolve the error message "Cannot locate the files required to open the database file." that occurs when opening SonicStage?
- What files does MaxDB Support require if the database has crashed and was restarted again in the meantime?
- I cannot save files, Word Basic Error 7 occurs while saving a file ?