/* 輸入?yún)?shù)*/ 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 /* 一個(gè)現(xiàn)有的堆范圍被擴(kuò)展 */
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中有一個(gè)新的堆范圍 */
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:
/* 輸入?yún)?shù) */ 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 /*似乎我們已經(jīng)清楚此次釋放了。*/ END ELSE IF (an access exception occurs when memory at triggerAddr is read) DO bFoundChange = TRUE END
IF (bFoundChange) DO /*因?yàn)橹皟?nèi)存塊占用的空間被釋放了,所以堆占用的虛擬內(nèi)存范圍就改變了。*/
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網(wǎng)絡(luò)優(yōu)化 win2003使用技巧 win2003系統(tǒng)故障 服務(wù)器配置 專家答疑 更多的請(qǐng)看:http://www.qqread.com/windows/2003/index.Html跟蹤堆內(nèi)存塊
通過(guò)一種探測(cè)堆內(nèi)存提交的算法,堆內(nèi)存跟蹤列表會(huì)不斷地增長(zhǎng),如例1中所示。要注重的是,當(dāng)你的程序分配一個(gè)內(nèi)存塊時(shí),自定義的內(nèi)存分配代碼也能跟蹤到這些內(nèi)存塊,并使用例1中的算法來(lái)更新包含內(nèi)存塊的堆列表。假如一個(gè)內(nèi)存塊的分配導(dǎo)致了額外的虛擬內(nèi)存被提交,那么被內(nèi)存塊占用的虛擬內(nèi)存會(huì)在之前就釋放,或許之前就被用作別的用途。在任一情況中,必須有條件地更新堆范圍跟蹤列表: l 假如正在跟蹤已提交范圍的基地址,此時(shí)必須更新范圍的大小,以指示出新的范圍上限。