Stay organized with collections
Save and categorize content based on your preferences.
open class TransactionTooLargeException : RemoteException
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. TransactionTooLargeException
is thrown as a heuristic when a transaction is large, and it fails, since these are the transactions which are most likely to overfill the transaction buffer.
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 constraints 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.
Summary
Inherited functions |
From class RemoteException
RuntimeException |
rethrowAsRuntimeException()
Rethrow this as an unchecked runtime exception.
Apps making calls into other processes may end up persisting internal state or making security decisions based on the perceived success or failure of a call, or any default values returned. For this reason, we want to strongly throw when there was trouble with the transaction.
|
RuntimeException |
rethrowFromSystemServer()
Rethrow this exception when we know it came from the system server. This gives us an opportunity to throw a nice clean DeadSystemRuntimeException signal to avoid spamming logs with misleading stack traces.
Apps making calls into the system server may end up persisting internal state or making security decisions based on the perceived success or failure of a call, or any default values returned. For this reason, we want to strongly throw when there was trouble with the transaction.
|
|
Public constructors
TransactionTooLargeException()
TransactionTooLargeException(msg: String!)
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# TransactionTooLargeException\n\nAdded in [API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nTransactionTooLargeException\n============================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/os/TransactionTooLargeException \"View this page in Java\") \n\n```\nopen class TransactionTooLargeException : RemoteException\n```\n\n|---|---|---|---|---|----------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||||||\n| ↳ | [kotlin.Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html) |||||\n| | ↳ | [java.lang.Exception](../../java/lang/Exception.html#) ||||\n| | | ↳ | [android.util.AndroidException](../util/AndroidException.html#) |||\n| | | | ↳ | [android.os.RemoteException](/reference/kotlin/android/os/RemoteException) ||\n| | | | | ↳ | [android.os.TransactionTooLargeException](#) |\n\nThe Binder transaction failed because it was too large.\n\nDuring a remote procedure call, the arguments and the return value of the call are transferred as [Parcel](/reference/kotlin/android/os/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. [TransactionTooLargeException](#) is thrown as a heuristic when a transaction is large, and it fails, since these are the transactions which are most likely to overfill the transaction buffer.\n\nThe 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.\n\nThere 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.\n\nThe key to avoiding [TransactionTooLargeException](#) is to keep all transactions relatively small. Try to minimize the amount of memory needed to create a [Parcel](/reference/kotlin/android/os/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.\n\nIf you are implementing a service, it may help to impose size or complexity constraints 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.\n\nSummary\n-------\n\n| Public constructors ||\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [TransactionTooLargeException](#TransactionTooLargeException())`()` \u003cbr /\u003e |\n| [TransactionTooLargeException](#TransactionTooLargeException(kotlin.String))`(`msg:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` \u003cbr /\u003e |\n\n| Inherited functions ||\n|---|---|\n| From class [RemoteException](/reference/kotlin/android/os/RemoteException) |------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [RuntimeException](../../java/lang/RuntimeException.html#) | [rethrowAsRuntimeException](/reference/kotlin/android/os/RemoteException#rethrowAsRuntimeException())`()` Rethrow this as an unchecked runtime exception. Apps making calls into other processes may end up persisting internal state or making security decisions based on the perceived success or failure of a call, or any default values returned. For this reason, we want to strongly throw when there was trouble with the transaction. \u003cbr /\u003e | | [RuntimeException](../../java/lang/RuntimeException.html#) | [rethrowFromSystemServer](/reference/kotlin/android/os/RemoteException#rethrowFromSystemServer())`()` Rethrow this exception when we know it came from the system server. This gives us an opportunity to throw a nice clean `DeadSystemRuntimeException` signal to avoid spamming logs with misleading stack traces. Apps making calls into the system server may end up persisting internal state or making security decisions based on the perceived success or failure of a call, or any default values returned. For this reason, we want to strongly throw when there was trouble with the transaction. \u003cbr /\u003e | ||\n\nPublic constructors\n-------------------\n\n### TransactionTooLargeException\n\nAdded in [API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nTransactionTooLargeException()\n``` \n\n### TransactionTooLargeException\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nTransactionTooLargeException(msg: String!)\n```"]]