How to detect and estimate heap fragmentation in my C++ program?

前端 未结 6 464
鱼传尺愫
鱼传尺愫 2020-12-16 23:11

I\'m developing a VC++ NT service that is meant to operate continuously for many months. It uses VC++ runtime heap intensively. Clearly heap fragmentation can at some point

6条回答
  •  孤城傲影
    2020-12-16 23:36

    I agree with Tobias - making your own memory manager is an excellent way to do this. I know only a few developers I would trust to write this kind of code though...

    Another possibility is to do your own sort of garbage collection/consolidation on your objects every now and then - at low loads... i.e. your service can be inactive for a while while it "defragments" the memory it uses but I am not sure you can guarantee the behavior you want without your own memory management.

提交回复
热议问题