Posts Tagged ‘ apple

Snow Leopard下的JDK链接有问题

今天在SL下build JRex,在执行ant make的时候总是出现以下错误:

compile:
[javac] Compiling 86 source files to /Users/ijay/Projects/mozilla/embedding/JRex/classes
[javac] /Users/ijay/Projects/mozilla/embedding/JRex/src/java/netscape/javascript/JSObject.java:38: ?????? sun.plugin.javascript ??????
[javac] import sun.plugin.javascript.JSContext;
[javac] ^
[javac] /Users/ijay/Projects/mozilla/embedding/JRex/src/java/netscape/javascript/JSObject.java:172: ?????? sun.plugin.javascript ??????
[javac] if (c instanceof sun.plugin.javascript.JSContext)
[javac] ^
[javac] /Users/ijay/Projects/mozilla/embedding/JRex/src/java/netscape/javascript/JSObject.java:174: ?Ҳ???????
[javac] ???ţ? ?? JSContext
[javac] λ?ã? ?? netscape.javascript.JSObject
[javac] JSContext j = (JSContext) c;
[javac] ^
[javac] /Users/ijay/Projects/mozilla/embedding/JRex/src/java/netscape/javascript/JSObject.java:174: ?Ҳ???????
[javac] ???ţ? ?? JSContext
[javac] λ?ã? ?? netscape.javascript.JSObject
[javac] JSContext j = (JSContext) c;
[javac] ^
[javac] 4 ????

BUILD FAILED

检查了一下build.xml引入的JRex.properties,其中有一行内容如下:

classpath =${build};${java.home}/lib/plugin.jar;${java.home}/lib/deploy.jar;${java.home}/lib/jaws.jar

于是又挨个去找那几个jar包(其中“plugin.jar”最像),最终发现了问题:/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/plugin.jar(即“${java.home}/lib/plugin.jar”)是一个符号链接,指向“/System/Library/Frameworks/JavaVM.framework/Versions/A/Resources/Deploy.bundle/Contents/Home/lib/plugin2.jar”,而plugin2.jar不存在……
把原先的符号链接删除,重建链接指向…/plugin.jar,问题解决
已向apple提交该bug

  • Share/Bookmark

Mac OS X的内存管理策略

参考了apple的这篇官方文档。下面是我看了之后的理解,欢迎大家拍砖

先是有关三种内存空间的定义:

  • The active list contains pages that are currently mapped into memory and have been recently accessed.
  • The inactive list contains pages that are currently resident in physical memory but have not been accessed recently. These pages contain valid data but may be released from memory at any time.
  • The free list contains pages of physical memory that are not associated with any address space of VM object. These pages are available for immediate use by any process that needs them.

然后是内核页换出策略:

Paging Virtual Memory Out

The kernel continuously compares the number of physical pages in the free list against a threshold value. When the number of pages in the free list dips below this threshold, the kernel reclaims physical pages for the free list by swapping inactive pages out of memory. To do this, the kernel iterates all resident pages in the active and inactive lists, performing the following steps:

  1. If a page in the active list is not recently touched, it is moved to the inactive list.
  2. If a page in the inactive list is not recently touched, the kernel finds the page’s VM object.
  3. If the VM object has never been paged before, the kernel calls an initialization routine that creates and assigns a default pager object.
  4. The VM object’s default pager attempts to write the page out to the backing store.
  5. If the pager succeeds, the kernel frees the physical memory occupied by the page and moves the page from the inactive to the free list.

即:当free内存小于一个阈值时内核将做页交换,将active内存中最近未使用的内存移入inactive,将inactive中最近未使用的vo交换出去,并释放内存给free

最后是mac下malloc的实质:

Allocating and Accessing Virtual Memory

Applications usually allocate memory using the malloc routine. This routine finds free space on an existing page or allocates new pages using vm_allocate to create space for the new memory block. Through the vm_allocate routine, the kernel performs a series of initialization steps:

  1. It maps a range of memory in the virtual address space of this process by creating a map entry; the map entry is a simple structure that defines the starting and ending addresses of the region.
  2. The range of memory is backed by the default pager.
  3. The kernel creates and initializes a VM object, associating it with the map entry.

At this point there are no pages resident in physical memory and no pages in the backing store. Everything is mapped virtually within the system. When a program accesses the region, by reading or writing to a specific address in it, a fault occurs because that address has not been mapped to physical memory. The kernel also recognizes that the VM object has no backing store for the page on which this address occurs. The kernel then performs the following steps for each page fault:

  1. It acquires a page from the free list and fills it with zeroes.
  2. It inserts a reference to this page in the VM object’s list of resident pages.
  3. It maps the virtual page to the physical page by filling in a data structure called the pmap. The pmap contains the page table used by the processor (or by a separate memory management unit) to map a given virtual address to the actual hardware address.

首先是lazy加载,即调用malloc后只创建vo及其映射,并未真正分配内存。当首次对该vo进行读或写操作时,内核开始分配内存,即从free内存中申请页并清零,并将此页地址记入vo的常驻页中,随后将虚拟地址和物理地址通过pmap结构映射

最终的结论就是:mac系统中的可用内存大小是free + 部分inactive + 部分active,其中“部分inactive”和“部分active”都指“最近未使用的那部分”。而至于“最近使用”的部分应该隐含了两层意义:一、正在被某进程使用;二、之前使用该片内存页的进程已退出,但可能在被降级(active -> inactive,inactive -> free)之前该程序又启动新的进程,重复使用之前的内存页

  • Share/Bookmark

iTunes Store 中国 已开放注册

今天无意中发现iTunes Store中国已经可以注册了,于是注册并绑定了浦发的信用卡。看来苹果已经为iPhone进中国做好了准备了

  • Share/Bookmark

iPhone 3GS vs HTC Hero

iPhone 3GS vs HTC Hero – Dogfight, Pt 1

iPhone 3GS vs HTC Hero – Dogfight, Pt 2

iPhone 3GS vs HTC Hero – Dogfight, Pt 3

  • Share/Bookmark

applewoods: 2008 年 Apple 回顾 [zz]

原文: applewoods: 2008 年 Apple 回顧.

在向 2008 道別之前,讓我們來瞧瞧今年蘋果電腦有哪些大小事。有兩項主要的產品在今年幾乎占據了世界各地的新聞版面:iPhone 3G 在全球各地陸續推出,還有世上最薄最輕巧的筆記型電腦 MacBook Air

MacBook Air

Apple 在 2008 年一月再度以當時全世界最薄的筆記型電腦 MacBook Air 帶給業界嶄新的體驗。MacBook Air 具備 13.3 吋 LED 背光照明螢幕、全尺寸及背光照明的鍵盤,在最薄處僅有 0.4 公分 (0.16 吋),到最厚處的 1.9 公分,重量僅有 1.36 公斤 (3.0 磅).

802.11n使用 802.11n 無線技術,Apple 推出了 Time Capsule,這套資料備份裝置會使用 Mac OS X 10.5 Leopard 中的 Time Machine,透過無線方式自動備份多台 Mac 上的所有內容。Time Capsule 也可當作 802.11n 基地台,提供與 AirPort Extreme 基地台相同的無線網路功能。Apple 也在一月份將 Apple TV 更新為 “Take 2“,提供影片租借服務,只需花費 $2.99 美元 (舊片) 或 $3.99 美元 (新片) 即可租片。

iPhone 3G在七月 11 日,Apple 在 22 個國家或地區推出眾所期盼的 iPhone 3G,隨著 iPhone 3G 的推出,.Mac 的服務也進行更新並改名為 MobileMe,讓此服務更適用於 Windows 平台與服務。應用程式 (可從 App Store 取得) 也可讓開發人員為 iPhone 3G 與 iPod touch 設計相關的軟體與遊戲。iPhone 3G 隨後於十二月時也在台灣的中華電信服務據點正式推出。(applewoods 的另一位夥伴 Antony 在澳洲當地推出 iPhone 3G 的第一天,即在雪梨 Apple Store 外排隊,並買到了他的 iPhone 3G)。

看似新聞頭條都在繞著 iPhone 3G 打轉,不過 Apple 並未忘了 iPod。Apple 也更新了 iPod touch 並內建揚聲器,以及推出新的 iPod nano

iPod_family_2008_09.jpg

NBC Universal 在九月份時重回 iTunes Store,並為 iTunes、iPod 和 Apple TV 的使用者提供了許多電視節目。

在 Mac 的部分,Mac Pro 現在具備 8 核心作為其標準。MacBook ProMacBook 在二月份時提升了速度,而在十月份的時候,MacBook Pro 和 MacBook 都加入了 MacBook Air 一族,外觀採用一體成型的鋁質設計,讓整個 MacBook 系列的筆記型電腦功能更強,但也更為輕巧。除了兼顧環保並重新設計的 MacBook 系列,Apple 也推出了 24 吋 LED Cinema Display,標榜鋁質及鏡面外觀和 Mini DisplayPort。在四月份時,iMac 的速度升級到 3.06GHz。Apple 又再次領先業界,讓產品更為兼顧環保考量,並持續減低生產工作與產品對環境造成的衝擊。

在軟體的部分,Aperture 升級到 Aperture 2,2.1 的版本具備開放的外掛模組架構,讓協力廠商的開發人員可為 Aperture 編寫外掛模組、濾鏡效果等等。另外,因應 iPhone 3G 的推出,iTunes 8 也接著推出,包括了新的視覺化瀏覽界面、Genius 功能,並在 iTunes Store 上加入了超高畫質的電視節目進行販售。

Apple Store Sydney

六月 19 日時,Apple 在雪梨開設了其第一家 Apple Store 旗艦店,同時也是南半球的第一家。這家雪梨的 Apple Store 是 Apple 在全球第二大的 Apple Store,提供了最長的 Genius Bar。(Antony 在凌晨 3:30 即在這家 Apple Store 開幕前排隊。有興趣的話,可以瞧瞧這裡的照片。)

另外,在七月份時,中國的第一家 Apple Store 也在北京的三里屯開幕;Jack 的重量級同事前陣子剛好前往參觀,拍下一些照片留念!

link 1: 2008 in Review (MacCentre701)
link 2: 2007 年 Mac 回顧 (applewoods)
link 3: 2006 年回顧 (applewoods)
link 4: 2005 年蘋果回顧 (applewoods)

  • Share/Bookmark