Package 

Class BitmapPool


  • 
    public final class BitmapPool
    
                        

    Object pool for Bitmap instances to reduce GC pressure during scrolling. Reuses bitmaps of the same size instead of creating new ones. Thread-safe implementation using ConcurrentLinkedQueue and AtomicInteger.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public class BitmapPool.Companion
    • Constructor Summary

      Constructors 
      Constructor Description
      BitmapPool(Integer maxPoolSize)
    • Method Summary

      Modifier and Type Method Description
      final Bitmap acquire(Integer width, Integer height, Bitmap.Config config) Get a bitmap from the pool or create a new one.
      final Unit release(Bitmap bitmap) Return a bitmap to the pool for reuse.
      final Unit clearPool() Clear all pooled bitmaps.
      final String getStats() Get current pool statistics.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BitmapPool

        BitmapPool(Integer maxPoolSize)
    • Method Detail

      • acquire

         final Bitmap acquire(Integer width, Integer height, Bitmap.Config config)

        Get a bitmap from the pool or create a new one.

        Parameters:
        width - Desired width
        height - Desired height
        config - Bitmap configuration (RGB_565 or ARGB_8888)
      • release

         final Unit release(Bitmap bitmap)

        Return a bitmap to the pool for reuse.

        Parameters:
        bitmap - The bitmap to recycle (will be added to pool or recycled)