Hi all,

I was recently getting a lot of crashes from Google Analytics on an LG
Revolution that appeared very similar to the crashes detailed in these
threads:

http://groups.google.com/group/android-developers/browse_thread/thread/77c71953388f6ab1
http://stackoverflow.com/questions/5358014/android-httpclient-oom-on-4g-lte-htc-thunderbolt

What I understand is happening is that during the dispatch, the socket
that GA creates uses what ever the device's default buffer size is.
This would be fine on most phones (I tested on an HTC Evo 4G and HTC
Desire, they each create a 16K buffer by default), except on the LG
Revolution (and apparently the HTC Thunderbolt) it creates a 2MB
buffer by default instead.  Clearly, with 24MB of heap, dispatches
going out every 20 seconds or so, and a GC engine that tends to
fragment, this will lead to OOM errors pretty quickly.

I've filed a bug report with the GA team here:

http://code.google.com/p/analytics-issues/issues/detail?id=153

If anyone has been seeing this issue as well, I'd encourage you to
voice it there, or you could star the issue to see if we can't get the
team's attention.

In the meantime, I've implemented this stopgap measure to turn GA off
if my app is running on a phone that defaults to a huge buffer:

        Socket s = new Socket();
        int bufferSize = 0;
        try {
                bufferSize = s.getSendBufferSize();
        } catch (SocketException e1) {
                e1.printStackTrace();
        }
        Log.i(TAG, "Default buffer size: " + bufferSize);
        if(bufferSize > 1000000) {
                USES_GOOGLE_ANALYTICS = false;
                Log.e(TAG, "Default socket buffer too large, disabling GA");
        }

This goes in the Application class's onCreate method, or you could use
it in your launching Activity.  USES_GOOGLE_ANALYTICS is a global
variable that you would check anywhere you would log a GA event.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to