It works something like this:
- Bitmap objects live on the virtual heap
- Bitmap data lives somewhere else (native heap, mmap() region,
imagination land, whatever)
- Bitmap objects have an integer field which is actually a pointer to
a native struct, which in turn has width, height, stride, format,
pointer to data, etc.
- When you release() a Bitmap object, it *should* cause all of the
native storage to be released immediately.
If you don't release a Bitmap object, but you do stop using it, it
will be marked for finalization during the next GC. Some time after
the GC finishes, the finalizer thread runs, and calls release() to
release the native storage. On the next GC, the Bitmap object is
collected.
So... if the code holding the bitmaps knows that it no longer needs
them, it can free them quickly. If it doesn't, and just waits until
the Bitmaps stop being referenced by anybody, then you have to wait
for the finalization thread to do its work after the next GC, which
takes a little longer. The HeapWorker thread handles finalization,
and runs at normal priority, so it should happen fairly soon.
If the external allocation mechanism didn't exist, and you didn't
explicitly manage Bitmaps or manually call System.gc() with some
frequency, the app would just keep piling up bitmaps, gradually
forcing the system to kill other stuff to make room in. The mechanism
was added to force garbage collection to happen at "appropriate"
times, and to cause things to break if allocations seemed to be
getting out of control.
Unfortunately the "how much is too much" calculation is too obscure,
and the "can I have memory" mechanism is too simplistic (e.g. there is
no association between an allocation for X amount of bytes and the
Bitmap object that will use them), so it's hard to figure out why
things are broken and how one should fix them.
分享到:
相关推荐
Something about Moblin 2.0
something about javaScript maybe can help you
c and c++ through it you will realize something about data struct
It something about zoological garden how you create a and how you connect
Something about Java. As you can see it is the FAQ about JAVA.
Something About Nginx
SOMETHING ABOUT UNCTAD, UNCTAD IS A INTERNATIONAL ORGANISITION ,THIS PPT IS A SAMPLE INTRODUCTION ABOUT IT
You can find something from this file about API.
2013年九年级英语下册 Module 1 Travel Something about Travel文章背景材料 外研版
A wearable finger flexion monitor developed to measure hand function in individuals with hand dysfunction was evaluated for feasibility, measurement repeatability and reliability, fidelity of wireless...
关于机器学习的那些事。论文的报告,主要讲到机器学习中应该注意到的一些民间知识。
You can learn something from this file about API.
视频处理,行为识别公开数据集,20bn-something-something-v2-00.zip。v2-00~v2-19 基于RGB的Action Recognition相关的实验,频繁的使用到了Something-Something数据集; Something数据集是一个大型的带有标签的记录...
Something
jquery的一些文档和一些页面效果,适合初学者
关于AI的东西 该存储库用于记录我感兴趣的任何内容。
作者coderqiao,域名Something-About-3D-Touch,本文主要介绍Home Screen Quick Actions,即通过主屏幕的应用Icon,我们可以用3D Touch呼出一个菜单,进行快速定位应用功能模块相关功能的开发。 详细说明:...
解决On no!Something has gone wrong.
GitHub 读取jupyter报错Sorry, something went wrong. Reload?