delete does not remove objects from the heap in osx?

Considering the following code...

int* p;
p = new int;
*p = 42;
delete p;
cout << *p << endl;

...will still print the value 42 when compiled with g++ under osx 10.6. When I compile the same code under a linux install with g++, the value of *p is 0. Why is this?
Last edited on
deleting something just means you're not allocating space for it anymore. It doesn't mean the space is overwritten with anything else, it just means it can be.
Thanks!
So I can understand better how memory is used as a program runs, is there any tangible way I can watch or monitor storage allocated and deallocated throughout the execution of a program?
Last edited on
Topic archived. No new replies allowed.