/* 输入参数*/ ADDRESS triggerAddr SIZE triggerSize LIST a list of tracked heap ranges
IF (the virtual memory at triggerAddr is tracked on the list as part of a heap range) DO IF (triggerAddr + triggerSize > (the tracked upper boundary of that heap range)) DO /* 一个现有的堆范围被扩展 */
make system call(s) to determine the base and extent of the newly committed range that contains the addresses from triggerAddr to (triggerAddr + triggerSize)
update the size of the tracked heap range to indicate its new upper limit END END ELSE DO /* 在triggerAddr中有一个新的堆范围 */
make system call(s) to determine the base and extent of the newly committed range that contains the addresses from triggerAddr to (triggerAddr + triggerSize)
track the new committed range in the list of heap ranges END 例2:
/* 输入参数 */ ADDRESS triggerAddr SIZE triggerSize LIST a list of tracked heap ranges
IF (the virtual memory at triggerAddr is not tracked on the heap range list as part of a heap range) DO /*似乎我们已经清楚此次释放了。*/ END ELSE IF (an access exception occurs when memory at triggerAddr is read) DO bFoundChange = TRUE END
IF (bFoundChange) DO /*因为之前内存块占用的空间被释放了,所以堆占用的虚拟内存范围就改变了。*/
make system calls to determine the bases and extents of the tracked committed heap ranges in the immediate vicinity of the decommitted range that includes the addresses from triggerAddr to (triggerAddr + triggerSize)
/*更新堆范围跟踪,以反映剩余提交的范围 */
IF (any portion of the tracked heap range that contained the block at TriggerAddr is still committed) DO update the heap range list to track just the portion(s) of that range that remain committed END ELSE DO delete the list element that tracks the range END END QQread.com 推出Windows2003教程 win2003安装介绍 win2003网络优化 win2003使用技巧 win2003系统故障 服务器配置 专家答疑 更多的请看:http://www.qqread.com/windows/2003/index.Html跟踪堆内存块
通过一种探测堆内存提交的算法,堆内存跟踪列表会不断地增长,如例1中所示。要注重的是,当你的程序分配一个内存块时,自定义的内存分配代码也能跟踪到这些内存块,并使用例1中的算法来更新包含内存块的堆列表。假如一个内存块的分配导致了额外的虚拟内存被提交,那么被内存块占用的虚拟内存会在之前就释放,或许之前就被用作别的用途。在任一情况中,必须有条件地更新堆范围跟踪列表: l 假如正在跟踪已提交范围的基地址,此时必须更新范围的大小,以指示出新的范围上限。