So I have an image slider which is a ViewPager with an image that you can swipe horizontal to move to the next one.
Before loading new images into the image slider I call mBitmap.recycle() on each bitmap to make sure I'm not wasting memory
Checking the memory monitor in Android studio reveals that in Android 4.4 (Dalvik) this works properly and every time new images are loaded, it always goes down to the amount of memory it uses when no images are loaded.
In Android 5.0 and up, that's not always the case. If you scroll sideways and view each image in the image slider at least once, when you go to load a new set of images, there's some leftover garbage that doesn't get collected, which is odd since I explicitly called recycle() on every image.
This crashes phones with lower heapSize (like 96MB), and on phones with larger heapsize (like 256 MB), you can compound this issue a couple times, up until about 100MB of uncollected garbage, and 90MB of legit used memory.
Once it hits that point of 190/256MB it seems like the garbage collection system starts "working" but I'm still not sure the Bitmap.recycle() calls that are actually doing the work. When the heap needs to readjust itself, it frees up a lot of memory each time, like 20MB, but simply invoking garbage collection (by clicking the button in Android studio) doesn't do that, it only removes the small amount of overhead when sliding between images.
So to summarize: Bitmap.recycle() is performing as expected if the images in the image slider / ViewPager are not seen, but if you see each of them at least once, the garbage collection somehow seems to be ignoring Bitmap.recycle()
Here's an image showing what exactly I'm talking about (this is for Android v5.0(ART), see the other image for v4.4(dalvik).
If you have any questions about my explanation of what's happening, I can clarify.
EDIT: Here's what it looks like when the same actions are performed on Android 4.4. Notice how every time recycle() is called it goes down to ~20MB of memory, which is about what my app uses not counting the bitmaps.