Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Bypassing java heap to operate images,will 100% avoid OOM (Maintenance stopped)绕过java heap操作图片,100%避开OOM

License

Notifications You must be signed in to change notification settings

BruceWind/OperatingImageBypassJavaHeap

Repository files navigation

OperatingImageBypassJavaHeap

中文

Announcement regarding discontinued maintenance in 2021:

In devices above Android 8.0, bitmaps store in native heaps. In the future, most devices will keep upgrading to new above 8.0, so this repo will be useless. This is why I have decided to stop maintaining it. I apologize to anyone who looks forward to updates.


The size of physical memory RAM has been increasing for a decade; the limitation of the Java heap exists, though. Furthermore, the camera is improved, and the size of the images that we need to operate keeps increasing. By the way, even though some brands or companies produce phones whose xmx has been modified, the limitations on those devices are still insufficient for immensely large images.

It is a fact that Android's JVMs such as Dalvik and ART accord with JVM standards. So that the Android JVM has a configuration with xmx.

In the README, I don't explain more about what xmx is. You can look into docs or websites for more about it.

Due to the limitation of Java heap for one application, while you operate large bitmaps, the device may throw OOM.

On the other hand, the native heap has no limitation. It is able to allocate reach physical size. So, operating images in the native heap can avoid OOM. In this repo, I bypass Bitmap. In case it bypasses bitmap, it will bypass the Java heap.

To sum up, the native heap is unlimited for every developer. This is why the repo works. All operations of images are in the native heap, which will completely avoid OOM.

The evidence for that the native heap doesn't have limitations.

click to expand

I have tried to allocate numerous memory in the native heap and don't execute free. The allocated memory exceeds 1G, which didn't give rise to OOM.

Below a picture, I run adb shell dumpsys meminfo PACKAGENAME to print that memory information.

The repo progress

  • rotate jpeg

  • compress jpeg

  • resize jpeg

  • compress png (2018.04.10)

    • provide other algorithms about compression, may introduce optipng, which has been used in most services or applications.
  • rotate png

  • resize png

Build tips

  1. before you run on the device, you need to put a test.jpg on external storage.

  2. After you start this app:

    test.jpg ----------compress/rotate---------> test2.jpg

Thanks

base on::bither-android-lib

github:libjpeg-turbo

source.android.com/...../dalvik_vm_properties

sourceforge:libjpeg

About

Bypassing java heap to operate images,will 100% avoid OOM (Maintenance stopped)绕过java heap操作图片,100%避开OOM

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages