{"id":3536,"url":"https://github.com/amitshekhariitbhu/GlideBitmapPool","last_synced_at":"2025-08-03T20:32:36.056Z","repository":{"id":43532787,"uuid":"61384984","full_name":"amitshekhariitbhu/GlideBitmapPool","owner":"amitshekhariitbhu","description":"Glide Bitmap Pool is a memory management library for reusing the bitmap memory","archived":false,"fork":false,"pushed_at":"2024-08-18T19:21:13.000Z","size":371,"stargazers_count":589,"open_issues_count":6,"forks_count":103,"subscribers_count":24,"default_branch":"master","last_synced_at":"2024-10-30T02:52:37.851Z","etag":null,"topics":["android","awesome","bitmap","bitmap-memory","bitmap-optimization","bitmap-pool","deallocation","decoding","glide","glide-bitmap-pool","inbitmap","optimization","reuse-memory"],"latest_commit_sha":null,"homepage":"https://outcomeschool.com","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amitshekhariitbhu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-17T15:48:57.000Z","updated_at":"2024-10-02T13:59:15.000Z","dependencies_parsed_at":"2024-07-27T16:11:24.586Z","dependency_job_id":"b64f1763-dac8-4aa4-bbd1-4c8dfb66f22e","html_url":"https://github.com/amitshekhariitbhu/GlideBitmapPool","commit_stats":{"total_commits":57,"total_committers":2,"mean_commits":28.5,"dds":0.01754385964912286,"last_synced_commit":"a7a37f5ccf134785f82a18ea018cc4192cd28eff"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amitshekhariitbhu%2FGlideBitmapPool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amitshekhariitbhu%2FGlideBitmapPool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amitshekhariitbhu%2FGlideBitmapPool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amitshekhariitbhu%2FGlideBitmapPool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amitshekhariitbhu","download_url":"https://codeload.github.com/amitshekhariitbhu/GlideBitmapPool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228540830,"owners_count":17934029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","awesome","bitmap","bitmap-memory","bitmap-optimization","bitmap-pool","deallocation","decoding","glide","glide-bitmap-pool","inbitmap","optimization","reuse-memory"],"created_at":"2024-01-05T20:16:44.280Z","updated_at":"2024-12-07T05:30:39.298Z","avatar_url":"https://github.com/amitshekhariitbhu.png","language":"Java","funding_links":[],"categories":["Uncategorized","Libraries","Java"],"sub_categories":["Uncategorized","GUI"],"readme":"# Glide Bitmap Pool \n\n\u003cimg src=https://raw.githubusercontent.com/amitshekhariitbhu/GlideBitmapPool/master/assets/glidebitmappool.png width=1000 height=140 /\u003e\n\n### About Glide Bitmap Pool\n\nGlide Bitmap Pool is a memory management library for reusing the bitmap memory. As it reuses bitmap memory , so \nno more GC calling again and again , hence smooth running application. It uses inBitmap while decoding the bitmap\non the supported android versions. All the version use-cases has been handled to optimize it better.\n\n* [Glide](https://github.com/bumptech/glide) , [Fresco](https://github.com/facebook/fresco) and [Fast Android Networking](https://github.com/amitshekhariitbhu/Fast-Android-Networking) uses Bitmap Pool Concept to \nload images efficiently.\n\n### Why use this library ?\n\nAn Image heavy Application decodes many images , so there will be continuous allocation and deallocation \nof memory in application , and that results in very frequent calling of GC(Garbage Collector). And \nfinally because of very frequent calling of GC , the application UI freezes.\nUse Bitmap pool to avoid continuous allocation and deallocation of memory in application \nand reduce GC overhead that will result in smooth running application.\nSuppose we have to load few bitmap in Android Application.\nWhen we load bitmapOne , it will allocate the memory for bitmapOne.\nThen if we don’t need bitmapOne , do not recycle bitmap (as if you recycle, it will make GC to be called) , \nso use this bitmapOne as an inBitmap for bitmapTwo so that , the same memory can be reused for bitmapTwo.\nIn this way , we can avoid continuous allocation and deallocation of memory in application and reduce GC overhead.\nBut the problem is that there are few restrictions as android version less than Honeycomb does not supports it , \nfew android version less than Kitkat only when we use inSampleSize = 1 , above that it supports \ncompletely and few other issues.\nSo , all these types of cases are handled in this library\n\n* [Refer this blog for detailed explanation](https://outcomeschool.com/blog/android-image-loading-library-use-bitmap-pool-for-responsive-ui)\n\n## Join **Outcome School** and get high paying tech job: [Outcome School](https://outcomeschool.com)\n\n#### GET RID OF : GC_FOR_ALLOC freed 1568K, 23% free 37664K/48844K, paused 141ms, total 143ms - (whenever you see this log , your application is lagging)\n\n\u003cimg src=https://raw.githubusercontent.com/amitshekhariitbhu/GlideBitmapPool/master/assets/gcsamplelog.png width=500 height=150 /\u003e\n\n## Requirements\n\nGlide Bitmap Pool can be included in any Android or Java application. \n\nGlide Bitmap Pool supports Android 2.3 (Gingerbread) and later. \n\n## Using Glide Bitmap Pool in your application\n\nAdd this in your `settings.gradle`:\n```groovy\nmaven { url 'https://jitpack.io' }\n```\n\nIf you are using `settings.gradle.kts`, add the following:\n```kotlin\nmaven { setUrl(\"https://jitpack.io\") }\n```\n\nAdd this in your `build.gradle`\n```groovy\nimplementation 'com.github.amitshekhariitbhu:GlideBitmapPool:1.0.0'\n```\n\nIf you are using `build.gradle.kts`, add the following:\n```kotlin\nimplementation(\"com.github.amitshekhariitbhu:GlideBitmapPool:1.0.0\")\n```\n\nThen initialize it in onCreate() Method of application class, :\n```java\nGlideBitmapPool.initialize(10 * 1024 * 1024); // 10mb max memory size\n```\n\n### Decoding the bitmap from file path\n```java\nBitmap bitmap = GlideBitmapFactory.decodeFile(filePath);\n```\n\n### Decoding the bitmap from resources\n```java\nBitmap bitmap = GlideBitmapFactory.decodeResource(getResources(), R.drawable.testImage);\n```\n\n### Decoding the down sample bitmap\n```java\nBitmap bitmap = GlideBitmapFactory.decodeFile(filePath,100,100);\n```\n\n### Making the bitmap available for recycle or reuse\n```java\nGlideBitmapPool.putBitmap(bitmap);\n```\n\n### Getting the empty bitmap from the pool\n```java\nBitmap bitmap = GlideBitmapPool.getBitmap(width, height, config);\n```\n\n### Clearing or Trimming Memory\n```java\nGlideBitmapPool.clearMemory();\nGlideBitmapPool.trimMemory(level);\n```\n\n### Migrating to Glide Bitmap Pool\n```java\n// ------   decoding -------\n\n// old code \nBitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.test1);\n\n// new code \nBitmap bitmap = GlideBitmapFactory.decodeResource(getResources(), R.drawable.test1);\n\n// ------   recycling ------- \n\n// old code\nbitmap.recycle();\n\n// new code\nGlideBitmapPool.putBitmap(bitmap);\n\n//  ------   creating a bitmap -------\n\n// old code \nBitmap bitmap = Bitmap.create(width, height, config);\n\n// new code\nBitmap bitmap = GlideBitmapPool.getBitmap(width, height, config);\n```\n\n### Important\n```\n// Do not use bitmap.recycle();\n// use GlideBitmapPool.putBitmap(bitmap); as it will put bitmap in the pool for further reuse.\n\n// Do not use Bitmap.create(width, height, config);\n// use GlideBitmapPool.getBitmap(width, height, config); as it returns bitmap from the pool that can be reused.\n```\n\n### Find this project useful ? :heart:\n* Support it by clicking the :star: button on the upper right of this page. :v:\n\n### Credits and references\n* [Glide](https://github.com/bumptech/glide) - As it uses the same bitmap pool that is used by [Glide](https://github.com/bumptech/glide)\n* [Managing Bitmap Memory](https://developer.android.com/training/displaying-bitmaps/manage-memory.html)\n* [Loading Large Bitmaps Efficiently](https://developer.android.com/training/displaying-bitmaps/load-bitmap.html)\n\n### TODO\n* More Optimization with further updates.\n\n### Check out another awesome library for fast and simple networking in Android.\n* [Fast Android Networking Library](https://github.com/amitshekhariitbhu/Fast-Android-Networking)\n\n### Another awesome library for debugging databases and shared preferences.\n* [Android Debug Database](https://github.com/amitshekhariitbhu/Android-Debug-Database)\n\nYou can connect with me on:\n\n- [Twitter](https://twitter.com/amitiitbhu)\n- [LinkedIn](https://www.linkedin.com/in/amit-shekhar-iitbhu)\n- [GitHub](https://github.com/amitshekhariitbhu)\n- [Facebook](https://www.facebook.com/amit.shekhar.iitbhu)\n\n[**Read all of our blogs here.**](https://outcomeschool.com/blog)\n\n### License\n```\n   Copyright (C) 2024 Amit Shekhar\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n```\n\n### Contributing to Glide Bitmap Pool\nAll pull requests are welcome, make sure to follow the [contribution guidelines](CONTRIBUTING.md)\nwhen you submit pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famitshekhariitbhu%2FGlideBitmapPool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famitshekhariitbhu%2FGlideBitmapPool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famitshekhariitbhu%2FGlideBitmapPool/lists"}