Getting Out of memory on a 2016016-byte allocation. error? Getting Out of memory on a 2016016-byte allocation. error? json json

Getting Out of memory on a 2016016-byte allocation. error?


Try this, if your minimum version of sdk is 11 or greater,

add following into application tag in your manifest

android:largeHeap="true"

some of people say that it is not best way but in my application it is working perfectly so i am suggesting you.

Hope it will help you.


After some research I got the problem. Actually the waveforms(data) is coming, but when I am clicking on back button, then it is not doing the clear the data. So I used bitmap.recycle().But it was doing crash my app. So I put it in a thread.Here is my code.

 @Overridepublic boolean onKeyDown(int keyCode, KeyEvent event) {    if (keyCode == KeyEvent.KEYCODE_BACK) {        Intent i = new Intent(this, MainActivity.class);        i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);        this.startActivity(i);        MusicManager.getInstance().stopIfPlaying();        new Handler().postDelayed(new Runnable() {            @Override            public void run() {                for (final TrackData track : SoundCloudManager                        .getInstance().mTrackData) {                    try {                        if (track.getBitmap() != null                                && !track.getBitmap().isRecycled()) {                            track.getBitmap().recycle();                            track.setBitmap(null);                            // finish();                        }                    } catch (Exception ex) {                        ex.printStackTrace();                    }                }                SoundCloudManager.getInstance().mTrackData.clear();                SoundCloudManager.getInstance().mTrackData = new ArrayList<TrackData>();            }        }, 1000);        System.gc();        Runtime.getRuntime().gc();        SoundCloudManager.getInstance().clearTask();        return true;    }    return super.onKeyDown(keyCode, event);}