3 ms·
> we just add a delete operator to free memory explicitly and an exception which is thrown if the program dereferences a pointer to freed memory. Is there any
by Ace17 7y ago
> we just add a delete operator to free memory explicitly and an exception which is thrown if the program dereferences a pointer to freed memory.
Is there any sensible thing to do when this exception is caught, appart from halting the program?
If the answer is "no", why have an exception at all?
- insulanus 7y agoBecause halting every time after the memory error happens is better than the system operating under the false assumption that the pointer is viable. Then they can patch it and re-deploy.
- corysama 7y agoLong ago I worked on a 3D scene exporter for 3DS MAX. It was complicated, unreliable code built on top of a complicated, unreliable interface. I put a big structured exception handler around the entire Export() process so that when random stuff went horribly wrong, I could pop up a dialog saying "The export failed. But, at least MAX didn't crash. An error has been logged. You should back up your work and restart MAX now."
- jcelerier 7y agothis alone is the main selling point of exceptions