开发者

With g++ is there a runtime setting to scramble freed memory with delete?

Does anyone know how I can for the g++ or gcc runtime to scramble the ram where an object was after delete? I have a theory that I'm using an 开发者_StackOverflow社区object after it has been deleted but in practice it rarely crashes.


I'd suggesting running with valgrind - that'll tell you if you're accessing memory after freeing it.


inline void operator delete(void* memblock) { //you custom stuff } would override the global. I used to use this for security so that we could zero out the memory so its less likely to leak important information.


You can overload delete for your object if you like.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜