private boolean allocate() {
        long start = clock.now();
        while (!toPrefill.isEmpty() && !isGcDetected(start)) {
            PreFillType toAllocate = toPrefill.remove();
            Bitmap bitmap = Bitmap.createBitmap(toAllocate.getWidth(), toAllocate.getHeight(),
                    toAllocate.getConfig());

            // Don't over fill the memory cache to avoid evicting useful resources, but make sure it's not empty so
            // we use all available space.
            if (getFreeMemoryCacheBytes() >= Util.getBitmapByteSize(bitmap)) {
                memoryCache.put(new UniqueKey(), BitmapResource.obtain(bitmap, bitmapPool));
            } else {
                addToBitmapPool(toAllocate, bitmap);
            }

            if (Log.isLoggable(TAG, Log.DEBUG)) {
                Log.d(TAG, "allocated [" + toAllocate.getWidth() + "x" + toAllocate.getHeight() + "] "
                        + toAllocate.getConfig() + " size: " + Util.getBitmapByteSize(bitmap));
            }
        }

        return !isCancelled && !toPrefill.isEmpty();
    }
Attempts to allocate {@link Bitmap}s and returns {@code true} if there are more
{@link Bitmap}s to allocate and {@code false} otherwise.
core/src/main/java/com/bumptech/glide/load/engine/prefill/BitmapPreFillRunner.java