OutOfMemory problem

by Kofa » Sun, 18 Apr 2010 17:50:22 GMT


Sponsored Links
 I really don't know why it's giving me this error...
I load an ImageView with an image of 692kb .jpg, using scroll options,
so you can scroll it around... the strange it's that when the mobile
it's connected to the VM it's less possible to happen.
So...how can I prevent this? is there anyway that I can free memory
when starting the app? can I tell the system to free memory before
loading the image? please show me the path =P....thx a lot!

--



OutOfMemory problem

by Streets Of Boston » Sun, 18 Apr 2010 23:59:28 GMT


 How big, in pixels, is the image?



>


Sponsored Links


OutOfMemory problem

by patbenatar » Mon, 19 Apr 2010 17:36:16 GMT


 You say your error doesn't happen as often if you are plugged into
your computer? Is that what you mean by VM? If so, that's likely
because you're developing your code at the time and every time you run
it on the device it kills and restarts your process.. leaving little
time for memory leaks to lead to OutOfMemory errors. Just FYI.

As for your OutOfMemory errors, this can be a really tough one to
debug.. Your app is leaking memory somewhere, but its hard to say
where. The image is not necessarily the problem, it could simply be
the tipping point that finally forces your app to crash. I would
recommend reading over all the articles tagged "Optimization" over at
 http://android-developers.blogspot.com 

-Nick







> >



OutOfMemory problem

by Kofa » Thu, 22 Apr 2010 02:56:07 GMT


 I'm looking at this blog about Optimization, thanks patbenatar.
The image it's 1920x1440 pixels, hope it helps.

--



OutOfMemory problem

by Kofa » Thu, 22 Apr 2010 02:57:22 GMT


 the image it's 1920x1440 pixels




> >



OutOfMemory problem

by Streets Of Boston » Thu, 22 Apr 2010 03:41:21 GMT


 1920p * 1440p * 2Bytes/p = 2764800*2 = 5529600 Bytes per image.

That's a big chunk and only a one time leak could cause your memory
issue.
Track your code and see where you possibly cache the reference to this
large Bitmap.
Note that memory used by Bitmaps (the internal array of bytes) is not
part of the DalvikVM and won't show up when you do java memory
profiling. However, this memory is part of the overall memory used by
the app's process.






> > >



Other Threads

1. spreadsheets.google.com using raw http/xml

It looks like my example refuses to work with spreadsheets.google.com list
worksheet feed.

Here is the code snippet
authenticate() succeeds and I get the proper auth token.
However getWorksheetContents() fails with 404 Not found error.

I have double check the URL (worksheetsheetURL) using curl (it works fine on
curl), I have checked the tcpdump of both curl and my sample program -
nothing seems out of the place - but i am at loss to understand, why I am
getting 404 error.

Any Gdata gurus here who can help?? I am using this raw approach since there
is no gdata apis for android yet.

public void authenticate() {
        HttpClient hClient = new DefaultHttpClient();
        HttpPost hPost = new HttpPost("
https://www.google.com/accounts/ClientLogin");

        List<NameValuePair> nameValuePairs = new
ArrayList<NameValuePair>(5);
        nameValuePairs.add(new BasicNameValuePair("Email","
xxxxxx...@gmail.com"));
        nameValuePairs.add(new BasicNameValuePair("Passwd","xxxxxx"));
        nameValuePairs.add(new BasicNameValuePair("accountType","GOOGLE"));
        nameValuePairs.add(new BasicNameValuePair("source","ExampleTest"));
        nameValuePairs.add(new BasicNameValuePair("service","wise"));
        try {
            hPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

            HttpResponse response = hClient.execute(hPost);

            int status = response.getStatusLine().getStatusCode();
            if(status == HttpStatus.SC_OK) {
                String temp = EntityUtils.toString(response.getEntity());
                authToken=getAuthString(temp);
            }

        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }


    public void getWorksheetContents() {
        HttpClient hClient = new DefaultHttpClient();
        HttpResponse response;

        HttpGet hGet = new HttpGet(worksheetsheetURL);
        hGet.addHeader("Authorization","GoogleLogin auth="+authToken);


        try {
            response = hClient.execute(hGet);

            int status = response.getStatusLine().getStatusCode();
            Log.d(TAG,"getWorksheetContents : "+response.getStatusLine());
            if(status == HttpStatus.SC_OK) {
                String temp = EntityUtils.toString(response.getEntity());
                Log.d(TAG, "getWorksheetContents"+temp);
            }
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public String getAuthString(String content) {
        int index=content.indexOf("Auth=");
        Log.d(TAG, "index = "+index);
        return content.substring(index+5);
    }

-Dan

-- 

2. Google Buzz 'breaks' privacy law

Have your say gentleman :)

http://news.bbc.co.uk/go/em/fr/-/2/low/technology/8519314.stm

----
Transmitted Using Green Robot 2.0

-- 
"Indonesian Android Community [id-android]" 

3. Sony Ericsson CEO: Google asked us to build the Nexus One, we refused

4. Can't show ProgressDialog during listview update

5. Can't show ProgressDialog during listview update

6. Restarting a MediaPlayer

7. mail to group