WinCE中劃分Storage Memory和Program Memory

首先解釋下這兩個東東

The RAM on a Windows CE–based device is divided into two areas: the object store and the program memory. The object store resembles a permanent, virtual RAM disk. Data in the object store is retained when you suspend or perform a soft reset operation on the system. Devices typically have a backup power supply for the RAM to preserve data if the main power supply is interrupted temporarily. When operation resumes, the system looks for a previously created object store in RAM and uses it, if one is found. Devices that do not have battery-backed RAM can use the hive-based registry to preserve data during multiple boot processes. The program memory consists of the remaining RAM. Program memory works like the RAM in personal computers — it stores the heaps and stacks for the applications that are running.

我承認我很懶,上面一段話的URL是ms-help://MS.WindowsCE.500/wcecoreos5/html/wce50conMemoryArchitecture.htm

具體的設置可以在系統啓動後,Control Panel -> System -> Memory 裏面看到。默認的是把內存五五開,一半給Storage Memory, 一半給Program Memory用。這樣顯然是不合算的。以64M的RAM爲例, 啓動後Storage Memory 32M, 而因爲沒有留出界面讓用戶往裏面拷東西, 任何時候in use都不會超過10M; Program Memory也是32M, 但啓動後就用掉27M, 實際上應用程序可用的內存只有5M, 一旦達到了上限, 那麼每前進一步都要很艱難地去釋放幾十K內存,然後用掉,再去釋放幾十K內存,如此循環,此時應用程序的運行速度狂慢無比. 劃分的方法也很簡單, 只不過可能沒人注意到而已. 說明在ms-help://MS.WindowsCE.500/wceosdev5/html/wce50lrfFSRAMPERCENT.htm

懶得看英文的人就繼續往下看 其實說白了就一句話, 在BSP的config.bib裏 CONFIG 區添加這個變量 FSRAMPERCENT = 0xXXXXXX, 但注意兩點,

(1) 必須寫在config.bib的CONFIG區裏, 不是plagform.bib不是config.reg等其他文件而是config.bib,也不是config.bib文件的任意地方而一定要在CONFIG REGION裏.

(2) FSRAMPERCENT這個變量一定得寫爲FSRAMPERCENT, 不能寫成FSROMPERCENT不能寫成ILOVEU, 或者阿貓阿狗什麼的.

 寫下這兩句的時候本人已經打開無敵光環, 免疫一切雞蛋和西紅柿.

FSRAMPERCENT是一個4byte長度的十六進制數, 我們用代數假設 FSRAMPERCENT = 0xQXYZ, 其中Q,X,Y,Z都是十六進制數 那麼最終劃分給Storage Memory的大小 = ( Q + X + Y + Z ) / 0x400 * TOTAL_RAM_SIZE 以文中的例子來算, FSRAMPERCENT=0x10203040, 假設TOTAL_RAM_SIZE=64M, 那麼StorageMemory= (0x10 + 0x20 + 0x30 + 0x40) / 0x400 * 64M = 10M.

順路鄙視一下,WinXP自帶的計算器裏無法輸入和計算帶小數位的非十進制數.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章