zoukankan      html  css  js  c++  java
  • How Default Heap Of Process Grows

    A Default Heap That Grows and Spreads

    In its simplest form, the default heap spans a range of addresses. Some ranges are reserved, while others are committed and have pages of memory associated with them. In this case the addresses are contiguous, and they all originated from the same base allocation address. In some cases the default heap needs to allocate more memory than is available in its current reserved address space. For these cases the heap can either fail the call that requests the memory, or reserve an additional address range elsewhere in the process. The default heap manager opts for the second choice.

    When the default heap needs more memory than is currently available, it reserves another 1-MB address range in the process. It also initially commits as much memory as it needs from this reserved address range to satisfy the allocation request. The default heap manager is then responsible for managing this new memory region as well as the original heap space. If necessary, it will repeat this throughout the application until the process runs out of memory and address space. You could end up with a default heap that manifests itself in your process in a manner similar to the heap represented in Figure 2.

    Figure 2. The default heap for each process can expand into free address regions within the process.

    So the default heap is not really a static heap at all. In fact, it may seem like a waste of energy to bother with managing the size of the initial heap since the heap always behaves in the same way after initialization. Managing the size of the default heap offers one advantage, though. It takes time to locate and reserve a new range of addresses in a process; you can save time by simply reserving a large enough address range initially. If you expect your application to require more heap space than the 1-MB default, reserve more address space initially to avoid allocating another region of addresses in your process later. Remember, each application has 2 gigabytes (GB) of address space to work with, and requires very little physical memory to support it.

  • 相关阅读:
    HTML连载29-div和span标签
    Java连载14-补码简介&浮点型整数
    Java连载13-整数型字面值的强制转换
    Java连载12-继承开发环境&long类型
    [Python] tkinter 之 Listbox & Combobox
    [Python] Tkinter command
    [java] 转型
    [Python] execl读写
    [c++] 细节
    [刷题] PTA 7-64 最长对称子串
  • 原文地址:https://www.cnblogs.com/taoxu0903/p/1023821.html
Copyright © 2011-2022 走看看