Problem solve Get help with specific problems with your technologies, process and projects.

Program memory requests

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.

This was last published in August 2000

Dig Deeper on Windows Server storage management

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.