<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1576552207286600828</id><updated>2024-10-24T15:04:30.208+08:00</updated><title type='text'>BrightCoreSoft</title><subtitle type='html'>邏輯, 演算法只是工具, 重要的是利用資訊科技來拉近心與心之間的距離</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://brightcoresoft.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1576552207286600828/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://brightcoresoft.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>yrulee</name><uri>http://www.blogger.com/profile/11428821818227495179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1576552207286600828.post-8476201402962662450</id><published>2010-04-07T20:10:00.000+08:00</published><updated>2010-04-07T20:10:07.349+08:00</updated><title type='text'>要搬家囉！</title><content type='html'>之後此blog將會搬到 &lt;a href=&quot;http://yrulee.wordpress.com/&quot;&gt;http://yrulee.wordpress.com/&lt;/a&gt; 囉&lt;br /&gt;
所有新文章將會只在上面的blog中發佈 :)</content><link rel='replies' type='application/atom+xml' href='http://brightcoresoft.blogspot.com/feeds/8476201402962662450/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://brightcoresoft.blogspot.com/2010/04/blog-post.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1576552207286600828/posts/default/8476201402962662450'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1576552207286600828/posts/default/8476201402962662450'/><link rel='alternate' type='text/html' href='http://brightcoresoft.blogspot.com/2010/04/blog-post.html' title='要搬家囉！'/><author><name>yrulee</name><uri>http://www.blogger.com/profile/11428821818227495179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1576552207286600828.post-1622183284845759790</id><published>2009-12-17T15:43:00.003+08:00</published><updated>2009-12-17T15:44:10.547+08:00</updated><title type='text'>初探JIT compiler 與 Android Dalvik VM</title><content type='html'>&lt;span style=&quot;border-collapse: separate; color: black; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;span style=&quot;line-height: 27px;&quot;&gt;筆者之前有研究過CDC VM (藍光播放器中的Java VM)，是SUN的RI (參考實作版)，從interperter, JIT compiler到GC都有看過原始碼, 最近也在看Android的Dalvik VM，以下有一些心得跟大家分享。&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;border-collapse: separate; color: black; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;span style=&quot;line-height: 27px;&quot;&gt;當然筆者的程度還很弱，不及許多已在Android或embedded system打滾多年的高手，但希望藉由以下的淺顯說明可以讓初階學習者了解JITcompiler 與 VM 的關係。&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;&lt;b style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot;&gt;1. Java的效能比較差嗎？&lt;/b&gt;&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;很多人都把runtime的效能當作絕對比較指標，但是他們常常忽略到的是&lt;b style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot;&gt;軟體開發的彈性與速度&lt;/b&gt;，在Java中透過標準API寫出一個類似MSN的聊天軟體(UI, data persistence, TCP/IP socket....etc)可能只需要N倍時間，但用C/C++可能需要3N甚至到10N以上的時間。&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;另外，現在能從SUN網站上download的JVM，都搭載了Just-In-Time compiler，這是一種動態Java method compiler，以Java method (A.doSomeThing())為單位，能夠動態的在程式執行時根據熱門程度編譯成機器碼(存至code cache)或只是直譯某個Java method，所以Sun也使用 &quot;Hot Spot&quot; VM作為產品名稱&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;所以，其實在JIT compiler的實作持續改進下，Java的程式執行效能已經近乎執行機器碼相同的速度。還以為Java執行效能比較差的人，其實已經落伍至少兩至三年以上&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;現在Sony PS3, HTC Magic/Hero裡，其實都有虛擬機器VM的足跡。(PS3 使用IBM的CDC VM)&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;&lt;b style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot;&gt;2. Android裡的VM效能如何？&lt;/b&gt;&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;首先，Android裡的VM不能稱為JVM，因為整個軟體開發框架中，&lt;u style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot;&gt;Java只存在於程式寫作階段&lt;/u&gt;，在deploy階段就已經被&lt;b style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot;&gt;dx&lt;/b&gt;這個tool，把.class轉換成.dex，這是一種特殊的binary格式，類似class，但是其有更先進的設計架構。&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;Android的VM稱為Dalvik VM，它只執行.dex檔，並且搭配Zygote(&lt;i style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot;&gt;Android OS中的process管理器，其會preload所有的系統library，每個獨立的Android程式有各自的process，但卻可以share同一份library，例如&lt;b style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot;&gt;android.os.*&lt;/b&gt;，這樣可以節省runtime記憶體&lt;/i&gt;)，以系統化的方式整合進Linux系統，因此DalvikVM相較於Sun實作的CDC/CLDC VM，有著更節省記憶體的優勢，這樣間接的讓整體系統運作速度變快很多。&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;此外，很有趣的是，當Sun不斷的以JIT為核心，甚至在CLDC VM中也有JIT時，Dalvik VM在第一時間卻不使用JIT技術。(註：Android 2.0 的dalvik已經有JIT implementation, for ARM)&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;原因無他，也是因為記憶體。&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;JIT compiler，就是compiler，其編譯bytecode(8位元指令)轉換為機器碼(16, 32 or 64位元指令)，這對於整體native code size是增加的，因此JIT compiler其實在嵌入式系統裡的記憶體使用量反而是增加的且間接的造成運作效能下降。因此DalvikVM只使用Intepreter作為bytecode execution engine。&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;什麼，這樣用intepreter不是更慢？&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;現在有試用過HERO的人就知道,其順暢程度直逼iPhone 3G，其原因就是其利用Java programming API與JNI的優勢，把常使用的功能切出來，盡量使用JNI直接用C/C++實作，再包裝成Java API，提供AP實作使用，例如Camera, GPS, Telephony, UI等API，因此Android程式一開始的進入點是interpreter執行沒錯，但到後期幾乎都是native code在運作。透過API隔開耗時與較不穩定的功能邏輯，AP實作者與系統廠各自分責，所以Android程式/OS的效能與一般也具有多工背景執行的OS相比，穩定且快速許多。&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;&lt;b style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot;&gt;總結&lt;/b&gt;&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;對Android解決了嵌入式 Java VM傳統的問題，但卻延展了Java的優點，並且以&lt;u style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot;&gt;優異的SDK為核心&lt;/u&gt;，統一了整個device/AP/market供應鏈，對大家皆有利益。&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;&lt;br style=&quot;font-family: Verdana,Arial,Helvetica,sans-serif;&quot; /&gt;當然Android也有許多缺點，例如&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;border-collapse: separate; color: black; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;span style=&quot;line-height: 27px;&quot;&gt;Android Framework版本持續變動，讓AP開發者必須經常變動API的使用方式。&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;border-collapse: separate; color: black; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;span style=&quot;line-height: 27px;&quot;&gt;Android Low Memory Killer號稱可以自動回收process，但實際上user還是需要手動砍，才能順暢使用&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;border-collapse: separate; color: black; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;span style=&quot;line-height: 27px;&quot;&gt;APK的DRM問題目前只有Google自己有解決方案，若有其他人想做第三方market，DRM問題依舊存在，因為只用AP層解決安全性較低。&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;</content><link rel='replies' type='application/atom+xml' href='http://brightcoresoft.blogspot.com/feeds/1622183284845759790/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://brightcoresoft.blogspot.com/2009/12/jit-compiler-android-dalvik-vm.html#comment-form' title='3 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1576552207286600828/posts/default/1622183284845759790'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1576552207286600828/posts/default/1622183284845759790'/><link rel='alternate' type='text/html' href='http://brightcoresoft.blogspot.com/2009/12/jit-compiler-android-dalvik-vm.html' title='初探JIT compiler 與 Android Dalvik VM'/><author><name>yrulee</name><uri>http://www.blogger.com/profile/11428821818227495179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1576552207286600828.post-8291471044673503951</id><published>2009-08-07T20:24:00.013+08:00</published><updated>2009-08-09T16:57:22.661+08:00</updated><title type='text'>Browser download function in Android</title><content type='html'>&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;http://1.bp.blogspot.com/_KUxuZy-iOGk/SnwhfHd6k1I/AAAAAAAAAKs/5iEkTYSrhYo/s1600-h/android_BrowserDownload.png&quot;&gt;&lt;img style=&quot;float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 400px; height: 229px;&quot; src=&quot;http://1.bp.blogspot.com/_KUxuZy-iOGk/SnwhfHd6k1I/AAAAAAAAAKs/5iEkTYSrhYo/s400/android_BrowserDownload.png&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5367201674382971730&quot; /&gt;&lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;最近在開發有關於檔案傳輸的Android程式，突然心血來潮去看Android Framework內建的瀏覽器下載功能是如何進行設計的，看過原始碼才知道，其完全遵守MVC原則，縱使只是一個單純的下載工具。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;右邊的圖顯示了概略的關係，並沒有使用正規UML，請多多包涵。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;現在就從DownloadService開始吧&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://www.google.com/codesearch?hl=zh-TW&amp;amp;q=DownloadService&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;http://www.google.com/codesearch?hl=zh-TW&amp;amp;q=DownloadService&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;一 - 下載工作執行 (Control)&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3366FF;&quot;&gt;classes:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;com.android.providers.downloads.&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;DownloadReceiver&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;com.android.providers.downloads.&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;DownloadService&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;com.android.providers.downloads.DownloadService.&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;UpdateThread&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;com.android.providers.downloads.&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;DownloadThread&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;實際上執行檔案下載的邏輯，其並無包含scheduling，任何task進來都是立即開始。&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;瀏覽器藉由新增DB record來觸發下載工作，&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;DownloadService&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;使用&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;UpdateThread&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;去monitor DB，若發現DB有需要處理的download工作，就會立刻new 出新的DownloadThread去handle實際的下載工作，並存有一份ArrayList (mDownloads)作為local memory cache&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;---------------------&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#FF0000;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;infinite for loop&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;--------------------&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;1. &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;text-decoration: underline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;比對mDownloads與DB中的record&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;1-1. 若DB的record比mDownloads還多，則代表有新的工作，立刻開始新的下載&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;1-2. 若DB的record比mDownloads還少，則代表有工作已經被使用者從UI刪除，立刻停止並刪除該下載&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;2. &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;text-decoration: underline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;通知Notification bar目前的狀態&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt; (請參照&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;四 - UI - 顯示狀態於Notification bar (View)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;------------------------------------------------------------&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;DownloadThread並會把下載狀態透過ContentResolver/ContentProvider介面隨時 persistent至 SQLite DB (DownloadProvider) 裡&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;二 - 下載資訊persistence (Model, 橘色部分)&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3366FF;&quot;&gt;classes:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;b&gt;&lt;/b&gt;com.android.providers.downloads.&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;DownloadProvider&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt; (implements ContentProvider with SQLite DB)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;儲存所有下載即時/歷史資訊的DB，其透過實作ContentProvider，可提供所有ap進行查詢&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;使用URI為 &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot; color: rgb(0, 136, 0);  white-space: pre; font-family:-webkit-monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;content://downloads/download &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot; color: rgb(0, 136, 0);  white-space: pre; font-family:-webkit-monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color: rgb(0, 0, 0);   white-space: normal; font-family:Georgia;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;(android.provider.&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;Downloads&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;.CONTENT_URI)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;三 - U&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;I - 下載歷史資訊列表 (View)&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3366FF;&quot;&gt;classes:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;com.android.browser.&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;BrowserDownloadPage&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;com.android.browser.&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;BrowserDownloadAdapter&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;當user點選menu中的下載歷史紀錄時，會顯示此Activity，其使用ListView + BrowserDownloadAdapter (繼承ResourceCursorAdapter，可方便透過Cursor介面撈DB中的資料並顯示於ListActivity中)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;四 - UI - 顯示狀態於Notification bar (View)&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3366FF;&quot;&gt;&lt;b&gt;classes:&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;com.android.providers.downloads.&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;DownloadNotification&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;DownloadService內部有UpdateThread，其會定時更新Notification bar中的狀態 (ProgressBar, 下載百分比)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;筆者之前寫過J2SE, J2ME BD-J等AP，在軟體架構上相較於Android可以發現，Android很重視 &lt;b&gt;data persistence&lt;/b&gt; (Preferences, ContentProvider....etc)與&lt;b&gt;XML modeling&lt;/b&gt; (UI, Animation, style....etc)，這讓AP開發者可以花更多的時間在需要的事情上，而不用擔心資料儲存的複雜狀態與程序，以及UI或Animaiton等畫面細節的調整&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://brightcoresoft.blogspot.com/feeds/8291471044673503951/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://brightcoresoft.blogspot.com/2009/08/browser-download-function-in-android.html#comment-form' title='1 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1576552207286600828/posts/default/8291471044673503951'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1576552207286600828/posts/default/8291471044673503951'/><link rel='alternate' type='text/html' href='http://brightcoresoft.blogspot.com/2009/08/browser-download-function-in-android.html' title='Browser download function in Android'/><author><name>yrulee</name><uri>http://www.blogger.com/profile/11428821818227495179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_KUxuZy-iOGk/SnwhfHd6k1I/AAAAAAAAAKs/5iEkTYSrhYo/s72-c/android_BrowserDownload.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1576552207286600828.post-8313146993740962869</id><published>2009-06-11T23:23:00.006+08:00</published><updated>2009-06-12T12:33:00.355+08:00</updated><title type='text'>讀後感: Android Dalvik VM vs. Java VM</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;在拜讀jserv大的此文章　&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot; white-space: pre; font-family:Arial;&quot;&gt;&lt;a href=&quot;http://jserv.blogspot.com/2009/05/android-dalvik-vm-vs-java-vm.html&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;Android Dalvik VM vs. Java VM&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;　後，有一些感想&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;其實此專案點出一個重點，就是DalvikVM 的bytecode execution效能普遍沒有現有的CDC/CLDC VM來的好，&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;一方面是&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;DalvikVM沒有JIT&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;，一方面是&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;發展的時間不夠久&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;當初DalvikVM不做JIT的原因是手持式裝置記憶體過小，太多的native code反而會造成記憶體管理上的負荷。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;但是他們也認知到未來若Android porting至小筆電，JIT的需求會越來越明顯，因此&lt;/span&gt;&lt;a href=&quot;http://groups.google.com/group/android-developers/browse_thread/thread/c4a8b4d97f408b17/f469cfe03cc49b25?pli=1&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;DalvikVM JIT的確有放在DalvikVM的roadmap中&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;但反觀此專案的本質，&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;他們讓Android app能夠透過此另類的middleware在任何的JavaVM上執行&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;，&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;我相信到後來他們一定會遇到一個困境：他們吸引不到大多數的programmer使用CLDC API撰寫Android app。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;DalvikVM在整個Android system framework只是一個小小的部份，其他強大的系統特性與API才是重點，&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot; white-space: pre; font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;所有的DalvikVM process皆由Zygote統籌管理並與DalvikVM合作，可以平行執行而不互相干擾&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;提供IBinder與AIDL方便撰寫IPC&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;dex load進來後內容可以由各個process共享，而不像JavaVM每一個process有各自的class loader&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;user可以一直開process而不需要提醒自己關閉，Low Memory Killer會主導與管理需要關閉的process，user永遠不會收到OOM (OutOfMemoryError)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot; white-space: pre; font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;app可以在簡訊或來電時接到通知&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;app可以控制手機上的 GPS, 發送簡訊, 甚至決定撥號與聯絡人操控介面&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;app之間可以透過Intent 互通有無&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;Android能夠迅速在市場上竄紅，就是其&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;系統化的思考&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;，以及與&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;AP層的緊密連結&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;，&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;而這個部份JavaVM永遠不可能做到，因為JavaVM永遠只是user space process。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;他們終究不可能把Android整個系統與API、或者類似的功能放到手機上，&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;而DalvikVM會實作JIT是可預見的未來。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-family:Arial;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:small;&quot;&gt;一點淺顯拙見，供大家參考。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://brightcoresoft.blogspot.com/feeds/8313146993740962869/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://brightcoresoft.blogspot.com/2009/06/android-dalvik-vm-vs-java-vm.html#comment-form' title='1 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1576552207286600828/posts/default/8313146993740962869'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1576552207286600828/posts/default/8313146993740962869'/><link rel='alternate' type='text/html' href='http://brightcoresoft.blogspot.com/2009/06/android-dalvik-vm-vs-java-vm.html' title='讀後感: Android Dalvik VM vs. Java VM'/><author><name>yrulee</name><uri>http://www.blogger.com/profile/11428821818227495179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1576552207286600828.post-1636347037628575560</id><published>2009-06-09T21:36:00.001+08:00</published><updated>2009-06-14T16:30:06.350+08:00</updated><title type='text'>Android : Low Memory Killer</title><content type='html'>&lt;div&gt;&lt;div&gt;Android DalvikVM不會丟出OOM的密技：就是直接砍掉你 &lt;a href=&quot;http://wiki.kldp.org/wiki.php/AndroidPortingOnRealTarget#s-3.1.5&quot;&gt;Low Memory Killer&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;user在手機上使用時，會開很多的process，當然每一段時間只會使用一個主process，所以其實LMK會砍掉的是不常被使用或是背景的process，所以不會影響到user experience&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;比起一般JVM會於heap不夠時立刻丟出OOM，其實LMK的方式對使用者的影響反而比較小，因為使用者再也不用&quot;關閉程式&quot;，系統會使用LMK來砍掉(也可以說幫忙關閉)舊的或不常使用的process&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Android是一個重視user experience的OS，這就是為什麼Android比J2ME更適合用於消費性電子的手機上&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;object width=&quot;425&quot; height=&quot;344&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/ptjedOZEXPM&amp;amp;hl=zh_TW&amp;amp;fs=1&amp;amp;&quot;&gt;&lt;param name=&quot;allowFullScreen&quot; value=&quot;true&quot;&gt;&lt;param name=&quot;allowscriptaccess&quot; value=&quot;always&quot;&gt;&lt;embed src=&quot;http://www.youtube.com/v/ptjedOZEXPM&amp;amp;hl=zh_TW&amp;amp;fs=1&amp;amp;&quot; type=&quot;application/x-shockwave-flash&quot; allowscriptaccess=&quot;always&quot; allowfullscreen=&quot;true&quot; width=&quot;425&quot; height=&quot;344&quot;&gt;&lt;/embed&gt;&lt;/object&gt;</content><link rel='replies' type='application/atom+xml' href='http://brightcoresoft.blogspot.com/feeds/1636347037628575560/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://brightcoresoft.blogspot.com/2009/06/android-low-memory-killer.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1576552207286600828/posts/default/1636347037628575560'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1576552207286600828/posts/default/1636347037628575560'/><link rel='alternate' type='text/html' href='http://brightcoresoft.blogspot.com/2009/06/android-low-memory-killer.html' title='Android : Low Memory Killer'/><author><name>yrulee</name><uri>http://www.blogger.com/profile/11428821818227495179</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>