I was using 'HttpUrlConnection' to connect to my server. I used to do so 
quite frequently, like once every 25 seconds or so.
After 20 minutes or so, the app crashes with various different errors. 
And strangely, the errors use to be activity related, like on a 'onClick' 
event for example.

After thorough debugging, I pin-pointed the issue to the use of 
'HttpUrlConnection'.
Later I figured out that the VM ran out of memory, due to the repeated use 
of 'HttpUrlConnection'.

I also read up that 'HttpUrlConnection' uses a pool, to facilitate faster 
connections.
BTW, after I'm done with the 'HttpUrlConnection' object, I make sure I 
close all open streams, and also disconnect.


I tried lot's of things to fix this, but I couldn't.
Finally I switched to DefaultHttpClient. And it worked perfectly well.
Leave the app running for over two hours, and it still holds up.

The funny part is, the more powerful the device, the more evident this is.
On Asus Transformer Prime and Nexus 7, this behaviour is more evident, than 
let's say on a Sony Experia M.
i.e. on a Sony Experia M, the app crashes much later than on a Asus and 
Nexus 7. 

*Asus Transformer Prime = 4.2.1*
*Nexus 7 = 4.3*


Is there a bug in the 'HttpUrlConnection' or the "connection pool" 
implementation?


Much interested to know what is going on??

Thanks 

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to