/* 輸入參數*/ 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 假如正在跟蹤已提交范圍的基地址,此時必須更新范圍的大小,以指示出新的范圍上限。