www.Walzer.cn - Tech & Management Blog

Focus on mobile dev
本博客文章,未在标题中写明转载的, 均为原创.
所谓高手,也就是熟悉别人制定的游戏规则、并且能在规则内跳舞的人。
posts - 107, comments - 654, trackbacks - 2, articles - 0
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

首先解释下这两个东东

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自带的计算器里无法输入和计算带小数位的非十进制数.
 

Feedback

#1楼  回复 引用 查看   

2006-05-14 21:06 by yakin      
先扔你个臭袜子,^_^

#2楼[楼主]  回复 引用 查看   

2006-05-24 17:48 by Walzer      
真恶, 矬人还没找个MM给你洗袜子啊

#3楼  回复 引用   

2006-08-29 12:13 by ake best[未注册用户]
猥琐得一塌糊涂,赞一个先~~~~~~~~~~~~

#4楼  回复 引用   

2007-04-25 15:53 by moon[未注册用户]
一看就是BSP菜鸟,FSRAMPERCENT要看你系统具体情况的,你改小了以后看看你copy文件或者拍照,bt传输的时候速度怎么样。而且也不一定非要在config.bib中,我写个xml来配置内存也可以阿,掌握深刻才能灵活应用!

#5楼[楼主]  回复 引用 查看   

2007-04-27 09:17 by Walzer      
回moon:
我已知的划分Storage Memory和Program Memory的方法一共有三种,也是MS文档中给出的三种方法
(1) statically using FSRAMPERCENT
(2) during boot using pOEMCalcFSPages
(3) using api SetSystemMemoryDivision
楼上所说的用XML来配置内存,具体是怎么操作的?是在pbxml文件里指定FSRAMPERCENT的值?也就是相当于在PlatformBuilder里的Platform Settings->Build Environment里添加FSRAMPERCENT的值?

我在WINCE BSP上只工作了一年,的确水平有限。即使是WINCE方面的文章,仍然自觉肤浅。不知楼上高手的博客地址多少,小弟登门拜读。

#6楼  回复 引用 查看   

2007-06-11 09:49 by Titan      
moon应该没有仔细阅读本文,没有深切领悟本文的高屋建瓴的思想境界。他的意思应该就是透过APP来call SetSystemMemoryDivision 函数啦

#7楼  回复 引用   

2007-07-16 09:05 by Argos[未注册用户]
FSRAMPERCENT的4个byte含义是不同的,尤其是Z。如果照你的算法,QXYZ作用都一样,最后加起来,为什么要搞四个参数,一个不就够了。顺便说一句,MSFT的文档里解释是对的,但他的例子用的公式显然只是一个特例。