Memory management is the act of managing computer memory. The essential requirement of memory management is to provide ways to dynamically allocate portions of memory to programs at their request, and free it for reuse when no longer needed. This is critical to any advanced computer system where more than a singleprocess might be underway at any time.[1]

内存管理的关键是提供动态分配程序要求的内存,不需要时释放它。

Several methods have been devised that increase the effectiveness of memory management. Virtual memory systems separate the memory addresses used by a process from actual physical addresses, allowing separation of processes and increasing the effectively available amount of RAM using paging or swapping to secondary storage. The quality of the virtual memory manager can have an extensive effect on overall system performance.

dynamic memory allocation:

The task of fulfilling an allocation request consists of locating a block of unused memory of sufficient size. Memory requests are satisfied by allocating portions from a large pool of memory called the heap or free store. At any given time, some parts of the heap are in use, while some are "free" (unused) and thus available for future allocations. Several issues complicate implementation, such as external fragmentation, which arises when there are many small gaps between allocated memory blocks, which invalidates their use for an allocation request. The allocator's metadata can also inflate the size of (individually) small allocations. This is managed often by chunking. The memory management system must track outstanding allocations to ensure that they do not overlap and that no memory is ever "lost" as a memory leak.

Efficiency[edit]

The specific dynamic memory allocation algorithm implemented can impact performance significantly. A study conducted in 1994 by Digital Equipment Corporation illustrates the overheads involved for a variety of allocators. The lowest averageinstruction path length required to allocate a single memory slot was 52 (as measured with an instruction level profiler on a variety of software).[2]

Implementations[edit]

Since the precise location of the allocation is not known in advance, the memory is accessed indirectly, usually through a pointer reference. The specific algorithm used to organize the memory area and allocate and deallocate chunks is interlinked with the kernel, and may use any of the following methods:

因为事先不知道分配的精确位置,内存被间接的访问。通常通过一个pointer reference,指令的算法用来管理内存通常和内核有关,可以使用以下的算法:

Fixed-size blocks allocation[edit]

Main article: Memory pool  (固定大小块分配,也叫内存池)

Fixed-size blocks allocation, also called memory pool allocation, uses a free list of fixed-size blocks of memory (often all of the same size). This works well for simple embedded systems where no large objects need to be allocated, but suffers from fragmentation, especially with long memory addresses. However, due to the significantly reduced overhead this method can substantially improve performance for objects that need frequent allocation / de-allocation and is often used in video games.

内存池分配,使用free-list来实现,这个工作良好在简单的嵌入式系统(没有large object需要分配),但是会产生碎片,特别是很长的内存地址,

Memory pools中文意思为内存池, ,内存池(Memory Pool)是一种内存分配方式。 通常我们习惯直接使用new、malloc等API申请分配内存,这样做的缺点在于:由于所申请内存块的大小不定,当频繁使用时会造成大量的内存碎片并进而降低性能。 内存池则是在真正使用内存之前,先申请分配一定数量的、大小相等(一般情况下)的内存块留作备用。当有新的内存需求时,就从内存池中分出一部分内存块,若内存块不够再继续申请新的内存。这样做的一个显著优点是尽量避免了内存碎片,使得内存分配效率得到提升。

Buddy blocks[edit]

For more details on this topic, see Buddy memory allocation.

In this system, memory is allocated into several pools of memory instead of just one, where each pool represents blocks of memory of a certain power of two in size. All blocks of a particular size are kept in a sorted linked list or tree and all new blocks that are formed during allocation are added to their respective memory pools for later use. If a smaller size is requested than is available, the smallest available size is selected and halved. One of the resulting halves is selected, and the process repeats until the request is complete. When a block is allocated, the allocator will start with the smallest sufficiently large block to avoid needlessly breaking blocks. When a block is freed, it is compared to its buddy. If they are both free, they are combined and placed in the next-largest size buddy-block list.

slab allocation algorithm

更多:

http://cuiyongxiu.com/tag/vs2010

最新文章

  1. spark 2.0 中 pyspark 对接 Ipython
  2. Spring中的cglib动态代理
  3. uva1635
  4. BizTalk动手实验(四)Schema开发测试
  5. c#图像处理入门(-bitmap类和图像像素值获取方法) 转
  6. eclipse 下生成jar包
  7. LoadRunner显示中文乱码的问题
  8. 嵌入式Linux USB WIFI驱动的移植
  9. JavaScript原型链demo
  10. HDU 4166 & BNU 32715 Robot Navigation (记忆化bfs)
  11. abs函数
  12. TP5常用命令符操作
  13. ASP.NET 异步返回的Action (编辑中。。。)
  14. va注解应用实例 - Annotation, 自定义注解, 注解类规则【转】
  15. 【转】MySQL-Select语句高级应用
  16. TP方法中打印地址栏中所有的参数:
  17. 项目- Vue全家桶实战去哪网App
  18. CSS选择器之兄弟选择器(~和+)
  19. Servlet各种路径、URL配置分析
  20. one by one 项目 part 2

热门文章

  1. Android(java)学习笔记170:Activity的生命周期
  2. C#面向对象(一)
  3. 第六篇:web之python框架之django
  4. PLSQL Developer操作
  5. php之常量小见
  6. JS判断是否是移动设备进行http链接重定向
  7. jquery 中$('.ui-selecter',this)这样写 是什么意思 求解释 见到都是这种$("div")
  8. XMPPFramework ios 例子中链接服务器失败,opnefire 服务器链接失败
  9. 【转载】介绍“Razor”— ASP.NET的一个新视图引擎
  10. gulp + browserSync 一起提高前端开发效率吧!