How much memory was actually allocated from heap for an object?

前端 未结 6 712
渐次进展
渐次进展 2020-12-30 17:09

I have a program that uses way too much memory for allocating numerous small objects on heap. So I would like to investigate into ways to optimize it. The program is compile

6条回答
  •  暖寄归人
    2020-12-30 17:13

    If you know you're going to do lots of small allocations and you're worried about memory fragmentation, why not allocate a single large buffer and then map into that? You'll probably see some performance improvements as well if you're doing a lot of allocating / deallocating.

    StackOverflow has some useful posts pertaining to avoiding memory fragmentation which might be of some use.

提交回复
热议问题