Tip

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

    Requires Free Membership to View

  1. 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 first published in August 2000

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
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
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.