I thought I'd provide an interesting look at how well LoadBitmapSample works.
My current Game App that I'm working on generates a Release APK of 10MBytes in size.
The App has the following bitmap sizes [in pixels] (quantity in parentheses):
(1) 1500x750
(1) 1280x1616
(1) 1280x866
(1) 996x129
(1) 857x277
(1) 534x854
(4) 690x282
(4) 282x282
(12) 460x320
(2) 160x160
(2) 150x75
(1) 380x180
[The following is performed in Debug(Legacy) mode to be able to see when the downsampling occurs]:
Prior to using LoadBitmapSample, and without using this line in the Manifest:
before there was extensive downsampling of images due to lack of memory (on the second orientation change). This also caused the GS3 to hang badly enough that I had to remove the battery to reset the device.
By adding the SetApplicationAttribute(android:largeHeap,"true") line to the Manifest, I was able to increase the number of orientation changes to six before downsampling occurred on the 7th
orientation change.
I then changed ALL of my bitmap loads to LoadBitmapSample, yielding the following greatly improved results:
Without the "largeHeap" line in the Manifest, I was able to achieve 11 orientation changes before getting an OutOfMemoryError on the 12th
orientation change.
AND ... by adding the "largeHeap" line to the Manifest, with all bitmap loads using LoadBitmapSample, I was able to increase to 33 ORIENTATION CHANGES before getting an OutOfMemoryError on the 34th ORIENTATION CHANGE.
WOW!!




Your Apps may give somewhat different results, but if you've shied away from using LoadBitmapSample, this shows how well it helps stave-off memory errors when loading bitmaps.
My current Game App that I'm working on generates a Release APK of 10MBytes in size.
The App has the following bitmap sizes [in pixels] (quantity in parentheses):
(1) 1500x750
(1) 1280x1616
(1) 1280x866
(1) 996x129
(1) 857x277
(1) 534x854
(4) 690x282
(4) 282x282
(12) 460x320
(2) 160x160
(2) 150x75
(1) 380x180
[The following is performed in Debug(Legacy) mode to be able to see when the downsampling occurs]:
Prior to using LoadBitmapSample, and without using this line in the Manifest:
SetApplicationAttribute(android:largeHeap,"true"),
I could only change the orientation of my Samsung Galaxy S3 once By adding the SetApplicationAttribute(android:largeHeap,"true") line to the Manifest, I was able to increase the number of orientation changes to six before downsampling occurred on the 7th
I then changed ALL of my bitmap loads to LoadBitmapSample, yielding the following greatly improved results:
Without the "largeHeap" line in the Manifest, I was able to achieve 11 orientation changes before getting an OutOfMemoryError on the 12th
AND ... by adding the "largeHeap" line to the Manifest, with all bitmap loads using LoadBitmapSample, I was able to increase to 33 ORIENTATION CHANGES before getting an OutOfMemoryError on the 34th ORIENTATION CHANGE.
WOW!!
Your Apps may give somewhat different results, but if you've shied away from using LoadBitmapSample, this shows how well it helps stave-off memory errors when loading bitmaps.
Last edited: