I'm creating an application that is using NativeAdsManager
within a RecyclerView
. When I load the ads, I'm getting an out of memory exception. This is where I initialise the NativeAdsManager
:
NativeAdsManager manager = new NativeAdsManager(MainActivity.this,PLACEMENT_ID,5);
manager.setListener(MainActivity.this);
manager.loadAds(NativeAd.MediaCacheFlag.ALL);
This is my log when I get the error:
07-07 16:44:37.513 14833-15332/com.example.fbads E/dalvikvm-heap: Out of memory on a 1324560-byte allocation.
07-07 16:44:37.528 14833-15332/com.example.fbads E/k: Error downloading image: https://external.xx.fbcdn.net/safe_image.php?d=AQAUgFkrAP5pYhO4&w=796&h=416&url=http%3A%2F%2Fwww.facebook.com%2Fads%2Fimage%2F%3Fd%3DAQJm1ZveY2ilC4oqvu3Hf63USTwVITC5XBV-qrlWjCWeNgKXrAn5SBB9J6cFyDL0sqpnMWqMDehXuXprwbAKycgE-kskX1q8_jpYlyB4sfhCxSRpHM_5n9ZA8-xhlcZ-VxlRs9DT4i5qeLy6kEZxOSQG&cfs=1&ext=jpg
java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
at android.graphics.BitmapFactory.decodeStreamInternal(BitmapFactory.java:620)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596)
at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:376)
at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:402)
at com.facebook.ads.internal.util.m.a(Unknown Source)
at com.facebook.ads.internal.util.k.b(Unknown Source)
at com.facebook.ads.internal.util.k.doInBackground(Unknown Source)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Any reasons why this is happening? Any suggestions on how to fix this problem?