質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.49%
Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Q&A

1回答

4145閲覧

暗黙的 Intent で Throwing OutOfMemoryError

fm311_engineer

総合スコア7

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

0グッド

0クリップ

投稿2017/09/21 15:51

編集2017/09/26 07:40

他人のアプリの暗黙的 Intent を受け取るアプリを開発中しています。
Intent を受け取り、アプリを落とさないまま遷移元のアプリから再度 Intent 呼び出しを繰り返すと OutOfMemoryError が発生します。(戻るボタンを押すとひとつ前の状態の画面に戻ります。OutOfMemoryError が発生するころには200MB~300MBほどになっている模様…?)
明示的 Intent の場合はメモリを破棄してから遷移することで解決できるようですが、今回の暗黙的 Intent の場合は遷移元が他人のアプリなのでどう対処するのかわからず質問させていただきました。

それと後回しで大丈夫なのですが、
遷移元(他人のアプリ)がどのような内容で暗黙的 Intent 呼び出しをしてるのか調べる方法はありませんか?
AndroidアプリやAndroid Studioの機能で
ブラウザ等が表示されていたのでとりあえず

<intent-filter> <action android:name="android.intent.action.SEND" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/plain" /> </intent-filter>

で受け取っているのですが、できれば範囲を狭くといいますか…、細かく指定したいです。

ログを追記します。

09-26 16:21:39.588 21464-21728/com.sample.teratest E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2 Process: com.sample.teratest, PID: 21464 java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:309) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354) at java.util.concurrent.FutureTask.setException(FutureTask.java:223) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.OutOfMemoryError: Failed to allocate a 518412 byte allocation with 409320 free bytes and 399KB until OOM at dalvik.system.VMRuntime.newNonMovableArray(Native Method) at android.graphics.BitmapFactory.nativeDecodeStream(Native Method) at android.graphics.BitmapFactory.decodeStreamInternal(BitmapFactory.java:635) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:611) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:649) at com.sample.teratest.AsyncTaskHttpRequest.doInBackground(AsyncTaskHttpRequest.java:44) at com.sample.teratest.AsyncTaskHttpRequest.doInBackground(AsyncTaskHttpRequest.java:21) at android.os.AsyncTask$2.call(AsyncTask.java:295) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)  at java.lang.Thread.run(Thread.java:818) 
… 09-26 16:21:40.020 21464-21730/com.sample.teratest I/art: Alloc concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 0% free, 191MB/192MB, paused 563us total 48.241ms 09-26 16:21:40.020 21464-21464/com.sample.teratest I/art: WaitForGcToComplete blocked for 43.241ms for cause Alloc 09-26 16:21:40.020 21464-21464/com.sample.teratest I/art: Starting a blocking GC Alloc 09-26 16:21:40.065 21464-21730/com.sample.teratest W/art: Suspending all threads took: 36.464ms 09-26 16:21:40.067 21464-21464/com.sample.teratest I/art: Clamp target GC heap from 207MB to 192MB 09-26 16:21:40.067 21464-21464/com.sample.teratest I/art: Alloc concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 0% free, 191MB/192MB, paused 500us total 45.333ms 09-26 16:21:40.068 21464-21464/com.sample.teratest W/art: Throwing OutOfMemoryError "Failed to allocate a 518412 byte allocation with 386344 free bytes and 377KB until OOM" 09-26 16:21:40.068 21464-21464/com.sample.teratest I/art: Starting a blocking GC Alloc 09-26 16:21:40.069 21464-21464/com.sample.teratest I/art: Starting a blocking GC Alloc 09-26 16:21:40.071 21464-21730/com.sample.teratest I/art: Forcing collection of SoftReferences for 506KB allocation 09-26 16:21:40.071 21464-21730/com.sample.teratest I/art: Waiting for a blocking GC Alloc 09-26 16:21:40.073 21464-21730/com.sample.teratest I/art: Starting a blocking GC Alloc 09-26 16:21:40.076 21464-21464/com.sample.teratest I/art: Waiting for a blocking GC Alloc 09-26 16:21:40.146 21464-21730/com.sample.teratest I/art: Clamp target GC heap from 207MB to 192MB 09-26 16:21:40.146 21464-21730/com.sample.teratest I/art: Alloc concurrent mark sweep GC freed 4(128B) AllocSpace objects, 0(0B) LOS objects, 0% free, 191MB/192MB, paused 2.941ms total 72.499ms 09-26 16:21:40.146 21464-21464/com.sample.teratest I/art: WaitForGcToComplete blocked for 70.111ms for cause Alloc 09-26 16:21:40.146 21464-21464/com.sample.teratest I/art: Starting a blocking GC Alloc 09-26 16:21:40.191 21464-21730/com.sample.teratest W/art: Suspending all threads took: 37.242ms 09-26 16:21:40.196 21464-21464/com.sample.teratest I/art: Clamp target GC heap from 207MB to 192MB 09-26 16:21:40.196 21464-21464/com.sample.teratest I/art: Alloc partial concurrent mark sweep GC freed 2(64B) AllocSpace objects, 0(0B) LOS objects, 0% free, 191MB/192MB, paused 561us total 44.993ms 09-26 16:21:40.197 21464-21730/com.sample.teratest W/art: Throwing OutOfMemoryError "Failed to allocate a 518412 byte allocation with 386312 free bytes and 377KB until OOM" 09-26 16:21:40.200 21464-21464/com.sample.teratest I/art: Starting a blocking GC Alloc 09-26 16:21:40.202 21464-21730/com.sample.teratest I/art: Waiting for a blocking GC Alloc 09-26 16:21:40.245 21464-21464/com.sample.teratest I/art: Clamp target GC heap from 207MB to 192MB 09-26 16:21:40.245 21464-21464/com.sample.teratest I/art: Alloc concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 0% free, 191MB/192MB, paused 565us total 44.183ms 09-26 16:21:40.246 21464-21730/com.sample.teratest I/art: WaitForGcToComplete blocked for 44.864ms for cause Alloc 09-26 16:21:40.246 21464-21730/com.sample.teratest I/art: Starting a blocking GC Alloc 09-26 16:21:40.247 21464-21730/com.sample.teratest I/art: Starting a blocking GC Alloc 09-26 16:21:40.249 21464-21464/com.sample.teratest I/art: Forcing collection of SoftReferences for 506KB allocation 09-26 16:21:40.249 21464-21464/com.sample.teratest I/art: Waiting for a blocking GC Alloc 09-26 16:21:40.254 21464-21730/com.sample.teratest I/art: Alloc sticky concurrent mark sweep GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 0% free, 191MB/192MB, paused 619us total 7.366ms 09-26 16:21:40.254 21464-21464/com.sample.teratest I/art: WaitForGcToComplete blocked for 5.086ms for cause Alloc 09-26 16:21:40.254 21464-21464/com.sample.teratest I/art: Starting a blocking GC Alloc 09-26 16:21:40.295 21464-21730/com.sample.teratest W/art: Suspending all threads took: 36.857ms 09-26 16:21:40.299 21464-21464/com.sample.teratest I/art: Clamp target GC heap from 207MB to 192MB 09-26 16:21:40.299 21464-21464/com.sample.teratest I/art: Alloc concurrent mark sweep GC freed 9(544B) AllocSpace objects, 0(0B) LOS objects, 0% free, 191MB/192MB, paused 3.201ms total 44.447ms 09-26 16:21:40.299 21464-21730/com.sample.teratest I/art: Waiting for a blocking GC Alloc 09-26 16:21:40.301 21464-21730/com.sample.teratest I/art: Starting a blocking GC Alloc 09-26 16:21:40.302 21464-21464/com.sample.teratest W/art: Throwing OutOfMemoryError "Failed to allocate a 518412 byte allocation with 386536 free bytes and 377KB until OOM" 09-26 16:21:40.303 21464-21464/com.sample.teratest D/AndroidRuntime: Shutting down VM 09-26 16:21:40.303 21464-21464/com.sample.teratest I/Process: Sending signal. PID: 21464 SIG: 9

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

yona

2017/09/21 17:55

エラーログを追記してください
fm311_engineer

2017/09/26 07:41

質問文にログを追加しました。よろしくお願いします。
yona

2017/09/26 07:49

com.sample.teratestはあなたのアプリケーションですか?
fm311_engineer

2017/09/26 08:08

はい、com.sample.teratest が私のアプリです。
guest

回答1

0

あなたのアプリ内にあるAsyncTaskHttpRequestの中でアウトオブメモリーが発生していますね。
戻るボタン時に適切に処理を中断し、メモリの解放処理を行うことで改善すると考えられます。

投稿2017/09/26 08:33

yona

総合スコア18155

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.49%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問