Article ID: 323635 - View products that this article applies to.
This article was previously published under Q323635
This article has been archived. It is offered "as is" and will no longer be updated.
Under stress conditions that involve heavy memory use, a program that was written in Visual C++ may perform better on a computer that is running Microsoft Windows NT 4.0 than on a computer that is running Microsoft Windows 2000 or Microsoft Windows XP.
When you start the program, it seems to have similar or better performance on a computer running Windows 2000 or Windows XP, and then, after physical memory (RAM) is exhausted, the memory manager starts to use the pagefile. When this occurs, the program on the computer running Windows 2000 or Windows XP may slow down compared to the same program on the computer running Windows NT 4.0. When you view the Task Manager on the computer running Windows 2000 or Windows XP, the CPU usage may peak at 100 percent.
Typically, programs that are written in Visual C++ make allocations through the C-Runtime (CRT). These allocations are handled differently on a computer running Windows NT 4.0 than on a computer running Windows 2000 or Windows XP. When the CRT detects that the program is running on Windows NT 4.0, it uses its own small-block heap for small allocations. The CRT does this to increase heap performance on Windows NT 4.0.
In Windows 2000 and Windows XP, the heap manager has been improved so that the CRT does not need the small-block heap. On a computer running Windows 2000 or Windows XP, the CRT sends all of the allocations to the default process heap. However, under stress conditions, the use of the small-block heap on a computer running Windows NT 4.0 may cause memory operations to be more efficient than the same operations on a computer running Windows 2000 or Windows XP.
You can force the use of the small-block heap on all operating systems. To do this, add the following code to the beginning of your program:
This code sets the small-block heap threshold to 1016 bytes, so that any allocations that have a size equal to or less than 1016 bytes are allocated on the private CRT heap. 1016 is the hard-coded value that MAX_ALLOC_DATA_SIZE is set to in the CRT source. The CRT uses MAX_ALLOC_DATA_SIZE as the default value to initialize the small-block heap on a computer running Windows NT 4.0.
Note There may be other differences between operating systems that cause performance variations. This is only one potential cause.
Typically, the performance difference occurs only when memory usage exceeds the physical memory. The symptoms also seem to be influenced by the types and amounts of allocations that the program makes.
To improve performance, you can also evaluate the application's memory usage. The following are examples of what conditions to look for:
For more information about memory and performance, visit the following Microsoft Web site:
Article ID: 323635 - Last Review: February 27, 2014 - Revision: 4.2