天极Yesky
  • 笔记本电脑
    笔记本
  • 台式电脑
    台式机
  • 手机
    手机
  • 电脑硬件DIY
    DIY硬件
  • CPU
    主板
    音箱
  • 硬盘
    显卡
    键鼠
  • 内存光驱
    显示器
    机箱电源

  • 数码相机DC
    数码相机
  • MP3播放器
    MP3/MP4
  • 数码摄像机DV
    摄像机
  • 电脑外设
    外设
  • 网络
    网络
  • 服务器
    服务器
  • 数字家庭
    数字家庭
  • 群乐
    群乐
  • 产品报价 行情 商家 新闻 评测 | 软件 设计 网页 开发 安全 论坛 E时代 游戏 图片 壁纸 下载 网摘 博客 索尼专区 Vista 科技奥运
    天极网
    Program memory requests
    作者: William H. Zack
    出处:
    责任编辑:
    [ 2004-06-17 19:12 ]


    This tip has been excerpted from Windows 2000 and Mainframe Integration, by Willian H. Zack, published by MacMillan Technical Publishing, 1999.

    Program memory requests
    By Hailey McKeefry

    Ultimately, all Windows 2000 programs request the memory that they need using the Win32 (most often using the VirtualAlloc and VirtualFree API calls). VirtualAlloc is used to allocate a range of pages in the virtual address space of the calling process. In this API, parameters can be used to specify whether memory is completely committed or whether the pages are reserved for the processes' use. You can also specify a number of additional parameters, such as whether the allocated memory is read-write or read-only and whether writes to memory are cached. VirtualFree is used to release a range of pages in the virtual address space of the calling process. You can specify the starting address and the size of the page region to be freed, and can also decommit a range of pages without freeing them.

    Windows 2000 allocates objects in memory from one of two memory pools: the paged pool, which is used for objects that can be paged into and out of memory; and the non-paged pool, which is used for system objects that cannot be paged out of memory.

    Memory is allocated and used in stages:

    1. A range of memory addresses can be reserved by a certain process, without being physically allocated in a paging file. This speeds operations, since only in-memory page tables must be updated.
    2. Then, when the process requires it, the application commits the memory, which actually allocates the backup storage in a paging file.
    3. When a program finishes with the memory, it will free the memory so that the pages in the paging file and the page frames are released for reuse.

    Ideally, the programs should use system memory in ways that preserve the resources of the system allocating only the memory that it needs when it needs it and freeing the memory when it is through, so that memory requests and memory releases match exactly. Some programs, though, suffer from memory leak, in which the program claims memory without freeing it. Severe leaks will bring the program and even the operating system to its knees. When creating programs, make sure to leverage the memory management tools within the operating system effectively. Tracking down these leaks in applications and operating systems components after the fact is hugely difficult.

    Hailey McKeefry is a contributing editor based in Belmont, Calif.

    For more information on Windows 2000 and Mainframe Integration, visit New Riders or InformIT.

    笔名:
    请您注意:

     遵守国家有关法律、法规,尊重网上道德,承担一切因您的行为而直接或间接引起的法律责任。

     天极网拥有管理笔名和留言的一切权利。
    相关内容