Glide Bitmap Pool is a memory management library for reusing the bitmap memory. As it reuses bitmap memory , so no more GC calling again and again which leads to smooth running application. It uses inBitmap while decoding the bitmap on the supported android versions. All the version use-cases has been handled to optimize it better.
Glide Bitmap Pool can be included in any Android or Java application.
Glide Bitmap Pool supports Android 2.3 (Gingerbread) and later.
Add this in your build.gradle
compile 'com.amitshekhar.android:glide-bitmap-pool:0.0.1'
Then initialize it in onCreate() Method of application class, :
GlideBitmapPool.initialize(10 * 1024 * 1024); // 10mb max memory size
Bitmap bitmap = GlideBitmapFactory.decodeFile(filePath);
Bitmap bitmap1 = GlideBitmapFactory.decodeResource(getResources(), R.drawable.testImage);
Bitmap bitmap = GlideBitmapFactory.decodeFile(filePath,100,100);
GlideBitmapPool.putBitmap(bitmap);
Bitmap bitmap = GlideBitmapPool.getBitmap(width, height, config);
// Do not use bitmap.recycle();
// use GlideBitmapPool.putBitmap(bitmap); as it will put in the pool for further reuse.
// Do not use Bitmap.create(width, height, config);
// use GlideBitmapPool.getBitmap(width, height, config); as it returns from the pool that can be reused.
- Glide - As it uses the same bitmap pool that is used by Glide
- Managing Bitmap Memory
- Loading Large Bitmaps Efficiently
- More Optimization with further updates.
Copyright (C) 2016 Amit Shekhar
Copyright (C) 2011 Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Just make pull request. You are in!