本文介绍了tcmalloc/jemalloc和内存池之间有什么区别(以及选择理由)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

tcmalloc/jemalloc是改进的内存分配器,并且还引入了内存池以实现更好的内存分配.那么它们之间有什么区别以及如何在我的应用程序中选择它们?

tcmalloc/jemalloc are improved memory allocators, and memory pool is also introduced for better memory allocation. So what are the differences between them and how to choose them in my application?

推荐答案

这取决于您程序的要求.如果您的程序有更多的动态内存分配,那么您需要从可用的分配器中选择一个内存分配器,它将产生最佳性能在您的程序之外.

It depends upon requirement of your program. If your program has more dynamic memory allocations, then youneed to choose a memory allocator, from available allocators, which would generate most optimal performanceout of your program.

要获得良好的内存管理,您至少需要满足以下要求:

For good memory management you need to meet the following requirements at minimum:

  1. 检查系统是否有足够的内存来处理数据.
  2. 您是否还在从可用内存中分配?
  3. 将已使用的内存/已释放的内存返回到池(程序或操作系统)

一个好的内存管理器的能力可以根据(至少)它的检索/分配和执行效率进行测试.返回/释放内存. (还有更多条件,例如缓存局部性,管理开销,VM环境,小型或大型环境,线程环境等.)

The ability of a good memory manager can be tested on basis of (at the bare minimum) its efficiency in retriving / allocating andreturning / dellaocating memory. (There are many more conditions like cache locality, managing overhead, VM environments, small or largeenvironments, threaded environment etc..)

关于tcmalloc和jemalloc,有很多人做过比较.参考其中一项比较:

With respect to tcmalloc and jemalloc there are many people who have done comparisions. With reference to one of thecomparisions:

http://ithare.com/testing-memory-allocators-ptmalloc2-tcmalloc-hoard-jemalloc-while-trying-to-simulate-real-world-loads/

tcmalloc在每个分配的CPU周期方面得分超过所有其他得分.jemalloc非常接近tcmalloc,但比ptmalloc(std glibc实现)更好.

tcmalloc scores over all other in terms of CPU cycles per allocation if the number of threads are less.jemalloc is very close to tcmalloc but better than ptmalloc (std glibc implementation).

就内存开销而言,jemalloc是最好的,其次是ptmalloc,其次是tcmalloc.

In terms of memory overhead jemalloc is the best, seconded by ptmalloc, followed by tcmalloc.

总体而言,可以说jemalloc在其他方面得分较高.您还可以在此处阅读有关jemalloc的更多信息:

Overall it can be said that jemalloc scores over others. You can also read more about jemalloc here:

https://www.facebook .com/notes/facebook-engineering/scalable-memory-allocation-using-jemalloc/480222803919

我刚刚引用了其他人进行和发布的测试,而自己还没有测试过.我希望这对您来说可能是一个很好的起点,并用它来测试和选择最适合的您的应用程序.

I have just quoted from tests done and published by other people and have not tested it myself. I hopethis could be a good starting point for you and use it to test and select the most optimal foryour application.

这篇关于tcmalloc/jemalloc和内存池之间有什么区别(以及选择理由)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 12:56