• 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.

  • 相关阅读:
    Linuxqq shell脚本安装后的卸载
    A Spy in the Metro UVA-1025(dp)
    L1-064 估值一亿的AI核心代码
    龙芯 3A4000 安装 Debian10 (via debootstrap)
    Linux用户和用户组
    /etc/issue、/etc/issue.net和/etc/motd的区别
    一种注释
    龙芯平台51单片机开发环境搭建笔记
    Rails UVA-514 (stack)
    The SetStack Computer UVA-12096 (set 操作)
  • 原文地址:https://www.cnblogs.com/taoxu0903/p/1023821.html
Copyright © 2020-2023  润新知