This advice is based on experience - I had worked with a terribly written huge (several megabytes of code) old software that had memory leaks, accessed already freed memory from multiple threads and so on. Also use stl containers when possible - they also offer bounds checking. In this case any outrageous out-of-bounds access will generate access violation and will be easy to track. If you are on linux, it probably have VirtualProtect alternative. Make a new/delete wrapper that locks unused/freed memory using VirtualProtect (yeah, I know that default allocation block will have to be PAGE_SIZE bytes large, and you'll need a lot of ram even for a small app, but that's the only disadvantage). IMO It might be a better idea to write custom memory manager (the one that supports new/delete/malloc/free wrappers).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |