编写自己的内存管理器 [英] Write your own memory manager
问题描述
我想写我自己的内存管理器。目标语言是C ++,内存管理器的目标主要是帮助调试。它应该检测双重释放,内存覆盖等。当然 - 我想了解内存管理。
有人可以给我一个提示,因此我可以学习如何编写这样的内存管理器的资源? / p>
感谢您的帮助。
非常有趣的项目,你可能从中学到很多。这里有一点关于内存管理主题的阅读材料。它讨论了内存管理的一些基础知识,引入一个简单的malloc实现,然后介绍几个更高级的主题。
此外,由于您提到您希望做一个有用的调试内存管理器,你可能想考虑由Memcheck / Valgrind(Linux的一个奇妙的内存调试器)的开发人员阅读本文。它详细说明了它们如何跟踪memchck中的所有元数据(无论特定字节是否被定义,初始化等)。这是一个有点详细,但它是如何使一个可扩展和高效的动态内存检查器的良好的阅读。
I'd like to write my own memory manager. The target language is C++ and the goal of the memory manager is mainly to help debugging. It should detect double frees, memory overwrite and so on. And of course - I'd like to learn about memory management.
Can someone give me a hint so resources where I can learn how to write such a memory manager?
Thank you for your help.
I think this is a very interesting project that you might learn a lot from. Here's a little bit of reading material on the subject of memory management. It goes over some of the basics of memory management, leads into a simple malloc implementation, then touches on a couple more advanced topics.
Also, since you mention that you want to make a memory manager that is useful for debugging, you may want to consider reading this paper by the developers of Memcheck/Valgrind (A wonderful memory debugger for Linux). It details how they track all the the metadata (whether or not a particular byte is defined, intialized, etc.) in memchck. It's a bit detailed, but it's good reading on how to make a scalable and efficient dynamic memory checker.
How to Shadow Every Byte of Memory Used by a Program
这篇关于编写自己的内存管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!