https://github.com/brucewind/juao
🚄 fast cache much more than JVM heap memory in Android.(在安卓上利用更多的物理RAM,快速地存取巨量的Java对象)
https://github.com/brucewind/juao
android bitmap bitmap-cache cache-storage java memory-cache memory-hacking
Last synced: 7 months ago
JSON representation
🚄 fast cache much more than JVM heap memory in Android.(在安卓上利用更多的物理RAM,快速地存取巨量的Java对象)
- Host: GitHub
- URL: https://github.com/brucewind/juao
- Owner: BruceWind
- License: apache-2.0
- Created: 2020-03-05T10:07:31.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-01-05T13:46:05.000Z (about 2 years ago)
- Last Synced: 2025-04-22T06:42:02.311Z (9 months ago)
- Topics: android, bitmap, bitmap-cache, cache-storage, java, memory-cache, memory-hacking
- Language: Java
- Homepage:
- Size: 1.35 MB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Juao 
[中文](https://github.com/BruceWind/Juao/blob/master/README_zh.md)
> [Juao](https://www.wikiwand.com/zh-cn/%E9%B3%8C) (巨鳌), a hugest animal in traditonal Chinese legend, looks like a tortoise could float up moutain or land from the ocean.

In most Android devices, enven though the physical memory (RAM) is very large, but often the memory that app can use is not much more than [JVM heap size](https://developer.android.com/topic/performance/memory#CheckHowMuchMemory).
When you have a huge amount of memory that needs to calculate on Android, may you think your can't alloc enough memory.
So I made this library. (It is fact that just few people get in the situation.)
If you need to deal with super-large image on devices which is lower than Android 8.0, you must need this library.
While your memory is caching in **Juao**, both put and pop will be very fast.
I made an example of caching Bitmap in there. The bitmap put and get from cache is really fast. In the example, I divided a panoramic image into many images, and then merged those to display.
I don't recommend using this repo to cache bitmaps on devices higher than 8.0, because [bitmap pixel data was already stored in native heap when device higher than 8.0](https://developer.android.google.cn/topic/performance/graphics/manage-memory).
In addition, I would enable about 40% of the physical RAM.
Currently,caching for **Bitmap, Parcelable, and Serializable** are supported by **Juao**. It capable of supporting other types.
I may develop caching byte[] in the future.
## How it work?
Use [DirectByteBuffer](https://chromium.googlesource.com/android_tools/+/2403/sdk/sources/android-22/java/nio/DirectByteBuffer.java)
to cache bytes on memory which is physical memory. If cache bytes over limitation that you set, bytes will be cached on disk.