꿈소년의 개발 이야기

android.os.TransactionTooLargeException 본문

Android Development

android.os.TransactionTooLargeException

꿈소년 2012. 6. 3. 18:06
반응형

출처 : http://developer.android.com/reference/android/os/TransactionTooLargeException.html



바인더가 처리할 양이 너무 커서 나타나는 exception 이다. 


보통 1mb 이내에 처리가 되어야 하는데 그 크기가 넘어서 생기는 문제이다. 


보통 쿼리를 던지거나 Parcel 로 큰 값을 던지는 경우에 발생한다. 


처리하는 부분을 다시 다듬어서 불필요하게 버퍼를 차지하는지 확인이 필요하다.


이하 내용은 좀 더 간략한 overview 이다. 


The Binder transaction failed because it was too large.

During a remote procedure call, the arguments and the return value of the call are transferred as Parcel objects stored in the Binder transaction buffer. If the arguments or the return value are too large to fit in the transaction buffer, then the call will fail and TransactionTooLargeException will be thrown.

The Binder transaction buffer has a limited fixed size, currently 1Mb, which is shared by all transactions in progress for the process. Consequently this exception can be thrown when there are many transactions in progress even when most of the individual transactions are of moderate size.

There are two possible outcomes when a remote procedure call throws TransactionTooLargeException. Either the client was unable to send its request to the service (most likely if the arguments were too large to fit in the transaction buffer), or the service was unable to send its response back to the client (most likely if the return value was too large to fit in the transaction buffer). It is not possible to tell which of these outcomes actually occurred. The client should assume that a partial failure occurred.

The key to avoiding TransactionTooLargeException is to keep all transactions relatively small. Try to minimize the amount of memory needed to create a Parcel for the arguments and the return value of the remote procedure call. Avoid transferring huge arrays of strings or large bitmaps. If possible, try to break up big requests into smaller pieces.

If you are implementing a service, it may help to impose size or complexity contraints on the queries that clients can perform. For example, if the result set could become large, then don't allow the client to request more than a few records at a time. Alternately, instead of returning all of the available data all at once, return the essential information first and make the client ask for additional information later as needed.


'Android Development' 카테고리의 다른 글

ANT build System을 통한 Android APK 빌드하기  (0) 2012.06.25
[MAT] Memory leak analysis tool  (0) 2012.06.08
ListView setTextFilterEnabled  (0) 2012.05.02
Source Insight + GVIM  (0) 2012.03.30
fragment 와 orientation  (0) 2012.03.26