diff options
| author | 2024-02-06 10:28:44 -0800 | |
|---|---|---|
| committer | 2024-04-02 11:35:43 -0700 | |
| commit | d48d873a2f6dfdcb3962b08bfa025ddb398bb57d (patch) | |
| tree | c072ee30e10f9ba053b1e9127503275e2ae220cd /libs/androidfw/misc.cpp | |
| parent | 9a885d7439b4dff37f15e562fb1b15e959f76caf (diff) | |
Add compressed bitmaps to be included in `am dumpheap`
Bug: 328443220
`android.graphics.Bitmap` class used to have a field of byte array
`mBuffer` for its content. This allowed the bitmap content to be
included as part of `am dumpheap`. However, this field was removed
when Bitmap was migrated to use native memory.
This CL allows contents of bitmaps to be compressed and included as
part of `am dumpheap`, with added command line switch '-b <format>'.
For example, the command below will include the contents of the
bitmaps compressed in PNG format as part of the heap dump.
`am dumpheap -b png com.google.android.apps.photos`
This is done with a few key changes below:
1. Every bitmap instance created will be tracked by a static
`WeakHashMap`. This is so that 1) the bitmap instances are
used as weak keys and can be garbage collected normally,
and 2) when a bitmap instance is garbage collected, its
entry in `WeakHashMap` will also be removed, so the size
of the map itself is limited
2. A static field `Bitmap.dumpData` is introduced, and will
record every bitmap's `nativePtr` and its compressed
content when bitmap dump is enabled during a heap dump
3. `Bitmap.dumpData` will be cleared after the heap is dumped,
the recorded information as well as buffers with compressed
contents will be garbage collected thereafter.
Change-Id: I37b6ea6b947565d1ac5a6bbc5b462c3ceedebec1
Diffstat (limited to 'libs/androidfw/misc.cpp')
0 files changed, 0 insertions, 0 deletions