黑莓手机BlackBerry Java应用性能优化,tips
来源:互联网 发布:软件开发模式包括 编辑:程序博客网 时间:2024/05/01 15:26
1. BlackBerry Object Handler要够用
程序不能消耗太多的对象句柄
2. 还是BlackBerry Object Handler,在Persistant Store的persistent object handles也是有限的,要节约使用
参考:Performance of the persistent store
(BlackBerry Manuals & Help > Documentation for Developers > Java Development Guides and API Reference > Data Storage - Development Guide - BlackBerry Java SDK - 7.0 > Performance of the persistent store)
5.TCP网络服务器返回数据给BlackBerry的最后要做flush动作,否则BlackBerry会等待超时,耗费很多时间
6.System.gc() 垃圾回收
参考1:displaying System busy icon
大意是说如果发现黑莓手机运行你的程序出现漏斗,估计是你的程序产生内存垃圾,内存碎片等,需要黑莓手机操作系统对内存进行整理。
而黑莓的内存整理是非常耗时的。
注意参考1中的日志细节:
VM:+GC(F)w=6
表明BlackBerry OS在做GC垃圾回收。
注意事项:
Looks like you are creating excess garbage. The system GC will kick in when memory becomes constrained, whether you called it or not.
Some things to look for:
* string concantenation, expecially within a for...next loop.
* unnec. use of Enumerations
* keeping references to objects that are no longer needed (set them to null)
There is a heirarchy to garbage collection on the BB. It goes something like this:
#1 - RAM collection of unused objects: < ~500 ms
#2 - Collection of unused objects in object cache (flash): ~1,000 ms, then repeat #1
#3 - Collection of unsued objects in store: ~2,000 ms, then repeat #2
参考2:BlackBerry: Taking Out the Trash: Garbage Collection (> Developers _ > Resources > Developer Journals > January 2005)
参考3:BlackBerry J2ME calling system.gc()
7: 谷歌搜索:blackberry Best Practices site:docs.blackberry.com
Best practice: Writing efficient code (5.0)
Best practice: Writing efficient code(4.6)
8. 一般性的Java内存使用问题
字符串使用,不再使用的对象句置null,尽量重用对象而不是反复生成并丢弃大量的小对象。
9. J2ME性能优化:移动网络环境下ReadBuffer的使用
by keyboardota
10. J2ME性能优化:程序开发要注意函数调用对性能的影响
刚开始,我一直集中精力在改进处理逻辑上,尽量减少处理路径,但这种做法收到的效果很不明显,基本上可以忽略不计;我也明白调用函数会引起效率的降低,但我一直以为这个损失的效率应该是很低的,也可以忽略不计,所以就没有过多的关注,直到有一天跟部门经理讨论时,他让我试把YUV to RGB的代码的函数调用都写在一起,没想到经过这么一改,性能提高不少,从原来每一帧的YUV to RGB需要耗时200多ms降为50多ms,让我大吃一惊。
因此,在J2ME开发中,如果在一些实时性要求很强的模块,尽量避免函数的调用,可以牺牲代码的可读性来换取更短的运行时间。
参考资料:
How to find that memory leak! (Part One)
How To Find That Memory Leak (Part Two): Detecting The Leak
How To Find That Memory Leak (Part Three): Why An Object is Leaking Into Memory
最后更新:2011.12.29
- 黑莓手机BlackBerry Java应用性能优化,tips
- BlackBerry 9850 大屏幕黑莓手机
- 黑莓BlackBerry手机辐射大小实测
- tips: 黑莓手机语音朗读英文
- 为什么黑莓手机(BlackBerry)在中国不能热卖?
- 黑莓blackberry手机刷ROM 的详细教程
- Java编程中“性能优化”相关Tips
- 黑莓开发者的第一个BlackBerry应用开发
- 黑莓开发者的第一个BlackBerry应用开发--搭建环境
- 黑莓开发者的第一个BlackBerry应用开发--创建主程序
- 黑莓开发者的第一个BlackBerry应用开发--设置模拟器
- 黑莓BlackBerry App World的应用数据(仅供参考)
- MySQL性能优化TIPS
- Android性能优化Tips
- 性能优化tips(一)
- 性能优化-代码-tips
- iOS性能优化Tips
- 黑莓开发环境搭建windows7+eclipse+BlackBerry Java Plug+JDK6
- Amazon的Dynamo研究
- shell 修改配置文件中含有特定字符串的行的值
- 回溯法之子集和问题
- 字体管理
- 如何成为一个C++高级程序员
- 黑莓手机BlackBerry Java应用性能优化,tips
- 坏心情
- MFC资源高级应用
- 给年轻程序员的7个建议
- 关于Dijkstra算法的实现
- ViewState视图状态
- iphone——Three20库代码初探
- 读书笔记_局部变量和栈帧.
- Mysql删除服务