nmtysh.log

Tech系のネタや日々の独り言などを書いています。

JIT を無効化する

Android 2.2 以降は JIT(Just In Time)コンパイラが有効になっています。

 

基本的には、有効にしておくと処理の高速化が期待できます。

しかし、意図的にJITを無効化したい場合があります。

 

そういった場合は AndroidManifest.xml の Application要素に android:vmSafeMode="true" を追加します。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

(snip)

<application android:icon="@drawable/icon" android:label="@string/app_name" android:vmSafeMode="true">

(snip)

</application>

<uses-sdk android:minSdkVersion="8" />

</manifest>

この状態でビルドして実機で実行すると JIT が無効化された状態で実行されます。

 

参考:

Android 2.2 Platform | Android Developers

リフレクションとJITの効果 - Kazzzの日記