原文地址:http://msdn.microsoft.com/en-us/library/aa366750(VS.85).aspx
[The information in this topic applies to Windows Server 2003 and Windows XP. Starting with Windows Vista, the system uses the low-fragmentation heap (LFH) as needed to service memory allocation requests. Applications do not need to enable the LFH for their heaps.]
[本主题中的信息适用于Windows Server 2003和Windows XP中。从Windows Vista开始,系统根据需要使用低碎片堆(LFH)来对内存分配的请求提供服务。应用程序并不需要启用LFH堆。]
Heap fragmentation is a state in which available memory is broken into small, noncontiguous blocks. When a heap is fragmented, memory allocation can fail even when the total available memory in the heap is enough to satisfy a request, because no single block of memory is large enough. The low-fragmentation heap (LFH) helps to reduce heap fragmentation.
堆碎片是一种状态,在这种状态,可用内存被分割成小的、不连续的块。当一个堆被碎片化后,内存分配会失败,即使总的可用内存是足够满足请求的,但单个块内存却不足够大。LFH可以帮助减少堆碎片。
The LFH is not a separate heap. Instead, it is a policy that applications can enable for their heaps. When the LFH is enabled, the system allocates memory in certain predetermined sizes. When an application requests a memory allocation from a heap that has the LFH enabled, the system allocates the smallest block of memory that is large enough to contain the requested size. The system does not use the LFH for allocations larger than 16 KB, whether or not the LFH is enabled.
LFH是应用可以采用的一种对堆使用的策略。当LFH被打开时,系统会用某种预估的size来分配内存。当应用从堆中请求内存时,系统会分配内存中比请求块大的最小的块。如果分配的size超过16KB,无论LFH打开与否都不会使用LFH。
An application should enable the LFH only for the default heap of the calling process or for private heaps that the application has created. To enable the LFH for a heap, use the GetProcessHeap function to obtain a handle to the default heap of the calling process, or use the handle to a private heap created by the HeapCreate function. Then call the HeapSetInformation function with the handle.
应用程序应该只对调用进程的默认堆和应用程序创建的私有堆打开这个选项。要启用LFH堆,进程使用GetProcessHeap来获取默认堆的句柄或使用HeapCreate函数来创建一个私有堆的句柄,然后用这个句柄使用HeapSetInformation函数
//注明:HeapCreate创建私有堆,GetProcessHeap获取进程堆。
//区别:1、如果你有一段短暂的堆活动,使用私有堆,可以比进程堆更快。2、私有堆的堆操作是线程安全的不需要同步。还有其他的原因,但是这两个是比较常见的。
The LFH cannot be enabled for heaps created with HEAP_NO_SERIALIZE or for heaps created with a fixed size. The LFH also cannot be enabled if you are using the heap debugging tools in Debugging Tools for Windows or Microsoft Application Verifier.
对使用HEAP_NO_SERIALIZE 创建的堆或者对固定大小的堆不能打开LFH选项。如果你在使用heap debugging tools in windbg 或者Appverifier,LFH也是不能打开的。
After the LFH has been enabled for a heap, it cannot be disabled.
一旦LFH被打开,就不能被关闭。
Applications that benefit most from the LFH are multi-threaded applications that allocate memory frequently and use a variety of allocation sizes under 16 KB. However, not all applications benefit from the LFH. To assess the effects of enabling the LFH in your application, use performance profiling data.
对于那些经常分配内存、并且分配大小小于16K的多线程程序而言,LFH是很有用的。但是,不是所有的应用都可以从LFH中获益。
原文地址:http://msdn.microsoft.com/en-us/library/aa366750(VS.85).aspx
[The information in this topic applies to Windows Server 2003 and Windows XP. Starting with Windows Vista, the system uses the low-fragmentation heap (LFH) as needed to service memory allocation requests. Applications do not need to enable the LFH for their heaps.]
[本主题中的信息适用于Windows Server 2003和Windows XP中。从Windows Vista开始,系统根据需要使用低碎片堆(LFH)来对内存分配的请求提供服务。应用程序并不需要启用LFH堆。]
Heap fragmentation is a state in which available memory is broken into small, noncontiguous blocks. When a heap is fragmented, memory allocation can fail even when the total available memory in the heap is enough to satisfy a request, because no single block of memory is large enough. The low-fragmentation heap (LFH) helps to reduce heap fragmentation.
堆碎片是一种状态,在这种状态,可用内存被分割成小的、不连续的块。当一个堆被碎片化后,内存分配会失败,即使总的可用内存是足够满足请求的,但单个块内存却不足够大。LFH可以帮助减少堆碎片。
The LFH is not a separate heap. Instead, it is a policy that applications can enable for their heaps. When the LFH is enabled, the system allocates memory in certain predetermined sizes. When an application requests a memory allocation from a heap that has the LFH enabled, the system allocates the smallest block of memory that is large enough to contain the requested size. The system does not use the LFH for allocations larger than 16 KB, whether or not the LFH is enabled.
LFH是应用可以采用的一种对堆使用的策略。当LFH被打开时,系统会用某种预估的size来分配内存。当应用从堆中请求内存时,系统会分配内存中比请求块大的最小的块。如果分配的size超过16KB,无论LFH打开与否都不会使用LFH。
An application should enable the LFH only for the default heap of the calling process or for private heaps that the application has created. To enable the LFH for a heap, use the GetProcessHeap function to obtain a handle to the default heap of the calling process, or use the handle to a private heap created by the HeapCreate function. Then call the HeapSetInformation function with the handle.
应用程序应该只对调用进程的默认堆和应用程序创建的私有堆打开这个选项。要启用LFH堆,进程使用GetProcessHeap来获取默认堆的句柄或使用HeapCreate函数来创建一个私有堆的句柄,然后用这个句柄使用HeapSetInformation函数
//注明:HeapCreate创建私有堆,GetProcessHeap获取进程堆。
//区别:1、如果你有一段短暂的堆活动,使用私有堆,可以比进程堆更快。2、私有堆的堆操作是线程安全的不需要同步。还有其他的原因,但是这两个是比较常见的。
The LFH cannot be enabled for heaps created with HEAP_NO_SERIALIZE or for heaps created with a fixed size. The LFH also cannot be enabled if you are using the heap debugging tools in Debugging Tools for Windows or Microsoft Application Verifier.
对使用HEAP_NO_SERIALIZE 创建的堆或者对固定大小的堆不能打开LFH选项。如果你在使用heap debugging tools in windbg 或者Appverifier,LFH也是不能打开的。
After the LFH has been enabled for a heap, it cannot be disabled.
一旦LFH被打开,就不能被关闭。
Applications that benefit most from the LFH are multi-threaded applications that allocate memory frequently and use a variety of allocation sizes under 16 KB. However, not all applications benefit from the LFH. To assess the effects of enabling the LFH in your application, use performance profiling data.
对于那些经常分配内存、并且分配大小小于16K的多线程程序而言,LFH是很有用的。但是,不是所有的应用都可以从LFH中获益。