[ 
https://issues.apache.org/jira/browse/THRIFT-4124?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16983336#comment-16983336
 ] 

Qinghui Xu commented on THRIFT-4124:
------------------------------------

> 
>`org.apache.thrift.async.TAsyncMethodCall.doReadingResponseSize(TAsyncMethodCall.java:250)`
> method is under your control and you could catch 1GB allocation request when 
>only 122 MB is available

My point is as OOM is like other runtime errors raised by some other API 
(`ByteBuffer.allocate` )that's used by thrift, and thrift does not necessarily 
know what to do with them. In this particular case of OOM, maybe some users 
would prefer to crash the jvm directly so they could spawn another one with 
bigger heap size, while others would consider this should be just a warning 
because they are just calling on some wrong endpoint (that's your scenario), so 
putting an error handling there will not fit the need of everybody.

[~jensg]: your suggestion sounds like a good way to avoid this kind of OOM. We 
can implement that for java binding, but is it expected to be on both server 
and client? Is there some spec/doc defining the behavior about this 
configuration?

 

> Connection to non-thrift server crashes android app
> ---------------------------------------------------
>
>                 Key: THRIFT-4124
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4124
>             Project: Thrift
>          Issue Type: Bug
>          Components: Java - Library
>    Affects Versions: 0.10.0
>         Environment: Android Studio
>            Reporter: Alexey Andronov
>            Assignee: Qinghui Xu
>            Priority: Major
>              Labels: async
>
> I connect to server like this:
> {code}m_client = new DispatchBackend.AsyncClient(
>     new TBinaryProtocol.Factory(),
>     new TAsyncClientManager(),
>     new TNonblockingSocket("google.com", 80)
> );{code}
> Then I execute request:
> {code}
> try {
>     m_client.request();
> } catch (TException e) {
>     // never reaches here
> }{code}
> And my app crashes with OOM error.
> The problem is that I can't catch exception from thrift library inside my 
> application i.e.
> inner library exception always crashes my app which is very sad.
> P.S. I tried to catch Throwable instead of TException and it didn't help
> Stacktrace:
> {code}E/art: Throwing OutOfMemoryError "Failed to allocate a 1213486172 byte 
> allocation with 3514240 free bytes and 122MB until OOM"
> E/AndroidRuntime: FATAL EXCEPTION: TAsyncClientManager#SelectorThread 9112
>    Process: com.myapp, PID: 20608
>    java.lang.OutOfMemoryError: Failed to allocate a 1213486172 byte 
> allocation with 3514240 free bytes and 122MB until OOM
>          at java.nio.ByteBuffer.allocate(ByteBuffer.java:56)
>          at 
> org.apache.thrift.async.TAsyncMethodCall.doReadingResponseSize(TAsyncMethodCall.java:250)
>          at 
> org.apache.thrift.async.TAsyncMethodCall.transition(TAsyncMethodCall.java:198)
>          at 
> org.apache.thrift.async.TAsyncClientManager$SelectThread.transitionMethods(TAsyncClientManager.java:143)
>          at 
> org.apache.thrift.async.TAsyncClientManager$SelectThread.run(TAsyncClientManager.java:113){code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to