注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

神魔破杜梓的叨叨堂

Programming every day!

 
 
 

日志

 
 
 
 

MXML 组件 VS ActionScript 组件–使用MXML创建的组件比使用Actionscript创建的组件占用的内存多吗?  

2008-04-09 09:20:23|  分类: My Tech |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
原文来自ntt.cc

I am working on an application which contains many components. I have been puzzled by a problem for a long time: Is the memory usage of components built with mxml tag bigger than that of components built in actionScript? I did a simple experiment below to find the truth.

 MXML 组件 VS ActionScript 组件–使用MXML创建的组件比使用Actionscript创建的组件占用的内存多吗? - hydra1983 - Edisons ClosetPreparation: use the codes below to add new mxml component:

  1. <mx:Button/> <mx:TextInput/>
  2. <mx:Button/> <mx:TextInput/>
  3. <mx:Button/> <mx:TextInput/>

Comment : use copy and paste command to get enough components for this experiment.

use the codes below to add new script component:

  1. var amount:Number = 1;
  2. for(var i:Number = 0 ; i < amount; i++)
  3. {
  4.     addChild(new Button());//addChild(new TextInput())
  5. }

Comment : use variable “amount” to control the amount of script component.

 MXML 组件 VS ActionScript 组件–使用MXML创建的组件比使用Actionscript创建的组件占用的内存多吗? - hydra1983 - Edisons ClosetEnvironment:

Hardware: Intel P4 3.0G | 1.93G RAM

Operation System: Windows XP sp2

Player: Flash Player 9.0.115

Flex SDK: Flex 2.0.1 Hotfix 3

 MXML 组件 VS ActionScript 组件–使用MXML创建的组件比使用Actionscript创建的组件占用的内存多吗? - hydra1983 - Edisons ClosetResult:

Without any Button :14596k(0)


With 1 MXML Button(1)

With 1 Script Button(2)

Differ Between(1-2)

Memory size

14984k

14852k

14984-14852=132

Differ with normal( i - 0)

14984-14596=388

14852-14596=256

132/1 = 132


With 30 MXML Button(1)

With 30 Script Button(2)

Differ Between(1-2)

Memory size

15528k

15352k

15528-15352=176

Differ with normal( i - 0)

15528-14596=932

15352-14596=756

176/30=5.8667


With 120 MXML Button(1)

With 120 Script Button(2)

Differ Between(1-2)

Memory size

17140k

16924k

17140-16924=216

Differ with normal( i - 0)

17140-14596=2544

16924-14596=2328

216/120 = 1.8


With 240 MXML Button(1)

With 240 Script Button(2)

Differ Between(1-2)

Memory size

18932k

18584k

18932-18584=348

Differ with normal( i - 0)

18932-14596=4336

18584-14596=3988

348/240=1.45

Without any TextInput:14596k(0)


With 1 MXML TextInput(1)

With 1 Script TextInput(2)

Differ Between(1-2)

Memory size

14988k

14896k

14988-14896=92

Differ with normal( i - 0)

14988-14596=392

14896-14596=300

92/1=92


With 4 MXML TextInput(1)

With 4 Script TextInput(2)

Differ Between(1-2)

Memory size

15024k

14968k

15024-14968=56

Differ with normal( i - 0)

15024-14596=428

14968-14596=372

56/4=14


With 30 MXML TextInput(1)

With 30 Script TextInput(2)

Differ Between(1-2)

Memory size

15588k

15300k

15588-15300=288

Differ with normal( i - 0)

15588-14596=992

15300-14596=704

288/30=9.6


With 120 MXML TextInput(1)

With 120 Script TextInput(2)

Differ Between(1-2)

Memory size

16740k

16520k

16740-16520=220

Differ with normal( i - 0)

16740-14596=2144

16520-14596=1924

220/120=1.8333


With 1000 MXML TextInput(1)

With 1000 Script TextInput(2)

Differ Between(1-2)

Memory size

30588k

29620k

30588-29620=968

Differ with normal( i - 0)

30588-14596=15992

29620-14596=15024

968/1000=0.968

 MXML 组件 VS ActionScript 组件–使用MXML创建的组件比使用Actionscript创建的组件占用的内存多吗? - hydra1983 - Edisons ClosetConclusion:

With the data displayed above , as the number of components increasing, the differences between the MXML component and script component is smaller and smaller. However, the amount of components we used is among a small number commonly. so , if we want to save some memory, it’s better to use script component than mxml component.

  评论这张
 
阅读(397)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017