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

  • 相关阅读:
    AOP实践--利用MVC5 Filter实现登录状态判断
    InstallShield12的安装破解方法
    phantomjs + python 打造一个微信机器人
    ASP.NET MVC4中@model使用多个类型实例的方法
    ssi技术
    ubuntu下面如何切换virtual_box的鼠标
    叫醒你的是闹钟,还是梦想?
    在linux命令行中直接执行php命令
    如何修改mysql默认的数据库密码
    【转】想要成功,请记住!
  • 原文地址:https://www.cnblogs.com/taoxu0903/p/1023821.html
Copyright © 2020-2023  润新知