検索
ホームページデータベースmysql チュートリアルJNI ERROR (app bug): accessed stale local reference

http://stackoverflow.com/questions/14765776/jni-error-app-bug-accessed-stale-local-reference-0xbc00021-index-8-in-a-tabl JNI ERROR (app bug): accessed stale local reference 解决办法: Since android 4.0 garbage collector was changed. Now it

http://stackoverflow.com/questions/14765776/jni-error-app-bug-accessed-stale-local-reference-0xbc00021-index-8-in-a-tabl


JNI ERROR (app bug): accessed stale local reference

解决办法:

Since android 4.0 garbage collector was changed. Now it moves object around during garbage collection, which can cause a lot of problems.

Imagine that you have a static variable pointing to an object, and then this object gets moved by gc. Since android uses direct pointers for java objects, this would mean that your static variable is now pointing to a random address in the memory, unoccupied by any object or occupied by an object of different sort. This will almost guarantee that you'll get EXC_BAD_ACCESS next time you use this variable.

So android gives you JNI ERROR (app bug) error to prevent you from getting undebugable EXC_BAD_ACCESS. Now there are two ways to avoid this error.

  1. You can set targetSdkVersion in your manifest to version 11 or less. This will enable JNI bug compatibility mode and prevent any problems altogether. This is the reason why your old examples are working.

  2. You can avoid using static variables pointing to java objects or make jobject references global before storing them by calling env->NewGlobalRef(ref).
    Perhaps on of the biggest examples here is keeping jclass objects. Normally, you'll initialize static jclass variable during JNI_OnLoad, since class objects remain in the memory as long as the application is running.


声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
MySQLにユーザーを追加:完全なチュートリアルMySQLにユーザーを追加:完全なチュートリアルMay 12, 2025 am 12:14 AM

MySQLユーザーを追加する方法を習得することは、データベース管理者と開発者にとって重要です。これは、データベースのセキュリティとアクセス制御を保証するためです。 1)CreateUserコマンドを使用して新しいユーザーを作成し、2)付与コマンドを介してアクセス許可を割り当て、3)FlushPrivilegesを使用してアクセス許可を有効にすることを確認します。

MySQL文字列データ型のマスター:Varchar vs. Text vs. CharMySQL文字列データ型のマスター:Varchar vs. Text vs. CharMay 12, 2025 am 12:12 AM

choosecharforfixed-lengthdata、varcharforvariable-lengthdata、andtextforlargetextfields.1)chariseffienceforconsistent-lengthdatalikecodes.2)varcharsuitsvariaible-lengthdatalikenames、balancingflexibilityandperformance.3)Textisidealforforforforforforforforforforforidex

MySQL:文字列データ型とインデックス:ベストプラクティスMySQL:文字列データ型とインデックス:ベストプラクティスMay 12, 2025 am 12:11 AM

MySQLの文字列データ型とインデックスを処理するためのベストプラクティスには、次のものが含まれます。1)固定長のchar、可変長さのvarchar、大規模なテキストのテキストなどの適切な文字列タイプを選択します。 2)インデックス作成に慎重になり、インデックスを避け、一般的なクエリのインデックスを作成します。 3)プレフィックスインデックスとフルテキストインデックスを使用して、長い文字列検索を最適化します。 4)インデックスを定期的に監視および最適化して、インデックスを小さく効率的に保つ。これらの方法により、読み取りと書き込みのパフォーマンスをバランスさせ、データベースの効率を改善できます。

MySQL:リモートでユーザーを追加する方法MySQL:リモートでユーザーを追加する方法May 12, 2025 am 12:10 AM

toaddauserremotelytomysql、フォローステープ:1)connecttomysqlasroot、2)createanewuserwithremoteaccess、3)grantniverayprivileges、and4)flushprivileges.

MySQL文字列データ型の究極のガイド:効率的なデータストレージMySQL文字列データ型の究極のガイド:効率的なデータストレージMay 12, 2025 am 12:05 AM

tostorestringseffiedlyinmysql、choosetherightdatatypebasedonyourneadss:1)usecharforfixed-lengthstringslikecountrycodes.2)usevarforvariable-lengthstringslikenames.3)usetextfor forlong-formtextcontent.4)useblobforborikedalikeimages

mysql blob vs.テキスト:大きなオブジェクトに適したデータ型を選択するmysql blob vs.テキスト:大きなオブジェクトに適したデータ型を選択するMay 11, 2025 am 12:13 AM

MySQLのBLOBおよびテキストデータ型を選択する場合、BLOBはバイナリデータの保存に適しており、テキストはテキストデータの保存に適しています。 1)BLOBは、写真やオーディオなどのバイナリデータに適しています。2)テキストは、記事やコメントなどのテキストデータに適しています。選択するときは、データプロパティとパフォーマンスの最適化を考慮する必要があります。

MySQL:製品にルートユーザーを使用する必要がありますか?MySQL:製品にルートユーザーを使用する必要がありますか?May 11, 2025 am 12:11 AM

いいえ、Youは、usotherootuserinmysqlforyourproduct.instead、createpificusers withlimitedprivilegestoenhancesecurityandperformance:1)createanewuserwithastrongpassword、2)grantonlynlyneversearpermissionStothisuser、3)正規環境筋肉筋周辺の環境

MySQL文字列データ型説明:データに適したタイプを選択するMySQL文字列データ型説明:データに適したタイプを選択するMay 11, 2025 am 12:10 AM

mysqlstringdatatypesshouldbechosenbadedatacharacteristicsandusecases:1)usecharforfixed-lengthstringslikecountrycodes.2)usevarforvariable-lengthstringslikenames.3)usebinaryorvarniaryforbinarydatalikecryptograpograpogrationckeys.4)使用

See all articles

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

Video Face Swap

Video Face Swap

完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

ホットツール

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

Dreamweaver Mac版

Dreamweaver Mac版

ビジュアル Web 開発ツール

MantisBT

MantisBT

Mantis は、製品の欠陥追跡を支援するために設計された、導入が簡単な Web ベースの欠陥追跡ツールです。 PHP、MySQL、Web サーバーが必要です。デモおよびホスティング サービスをチェックしてください。

SublimeText3 中国語版

SublimeText3 中国語版

中国語版、とても使いやすい

SublimeText3 英語版

SublimeText3 英語版

推奨: Win バージョン、コードプロンプトをサポート!