954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

quick C++ memory question

When a pointer is deleted, is the memory it is pointing to only returned to the heap or is it also nulled too? Thx

CPPRULZ
Junior Poster in Training
91 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

Who knows, that's for the implementation to decide.
- in release mode, it's typically back in the heap untouched.
- in debug mode, it could be filled with some specific pattern to mark "deleted data", and perhaps held in a "pending" list for a while. Specifically to assist with spotting any "use after free" errors in the code.

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You