History log of /dalvik/vm/alloc/HeapSource.cpp
Revision Date Author Comments
95adf1ff81dec324746bef58ba8c45dc1c8f3b50 22-Aug-2013 Mathieu Chartier <mathieuc@google.com> Fix native allocation tracking on Dalvik.

Fixed issue where we had inverted logic when checking for
pending exceptions.

Changed the logic to not update the native allocation watermarks
after concurrent GC since the finalizers may not have been run at
this point.

Copied over the test from ART for ensuring that it is working.

Bug: 10444866

Change-Id: Ie26170f9c4703f11e993233cdc9c5f46396fca84
eeb18914e487b4ae8c8702fc390fd1a360c768ae 15-Jul-2013 Hiroshi Yamauchi <yamauchi@google.com> Show size/alloc/free per Dalvik heap space in dumpsys

Add the heap size/alloc/free stats to the Dalvik heap space breakdown section in dumpsys meminfo.

Also, now the zygote heap has a distict ashmem region name.

Bug: 9532137
Bug: 8266259

(cherry picked from commit 3edfe0b32753309ad7dcccd894239cb0a8aefb85)

Change-Id: I9b32727e4211f571a5205b6b7281958514d245d4
478976606f43c8095c829a5b78d79ff50b4c43ef 15-Jul-2013 Hiroshi Yamauchi <yamauchi@google.com> Show size/alloc/free per Dalvik heap space in dumpsys

Add the heap size/alloc/free stats to the Dalvik heap space breakdown section in dumpsys meminfo.

Also, now the zygote heap has a distict ashmem region name.

Bug: 9532137
Bug: 8266259

(cherry picked from commit 3edfe0b32753309ad7dcccd894239cb0a8aefb85)

Change-Id: I9b32727e4211f571a5205b6b7281958514d245d4
3086ab6a9c0859af3a85d5df73d0aecc2c47ca89 16-Jul-2013 Mathieu Chartier <mathieuc@google.com> Backport native allocation tracking.

From:
https://googleplex-android-review.googlesource.com/#/c/328818/

Change-Id: I5a930e629c5a2062f01f870b4a44dcd98cb4ffe9
ebaf918e1bacff53c3dc3f0861c5cee851db23e5 10-Jul-2013 Mathieu Chartier <mathieuc@google.com> Add low memory mode option.

Added a low memory mode option which can be enabled by passing the
flag "-XX:LowMemoryMode" to the VM.

Changed dvmHeapSourceAlloc to use mspace_malloc and madvise page
aligned regions of allocations back to the kernel if low
memory mode is enabled. No measurable performance penalty on a
benchmark which does 4 million object allocations. This seems to
reduce the Dalvik total PSS by 10 - 15% on devices with
large bitmaps (such as manta or flo).

Another change is that cards are madvised instead of memset when
cleared if low memory mode is enabled. This saves a minor amount
of memory at the cost of having slightly more page faults.

Change-Id: I0c850bc370ebabf4393bff1c47d3257b2f1518d2
739bb122cfc866d599338a9def221e0661b54d20 17-Apr-2013 Elliott Hughes <enh@google.com> Work around a dalvik JDWP/GC deadlock.

Also add a few missing TEMP_FAILURE_RETRYs that can cause dalvik to
incorrectly decide that the debugger connection has been broken.

Bug: 8191824

(cherry picked from commit b680ae3140a789f182c26abf8df9645f7744113a)

Change-Id: I92736a1ad2f06caba30506d05bfa59fccbeee834
b680ae3140a789f182c26abf8df9645f7744113a 17-Apr-2013 Elliott Hughes <enh@google.com> Work around a dalvik JDWP/GC deadlock.

Also add a few missing TEMP_FAILURE_RETRYs that can cause dalvik to
incorrectly decide that the debugger connection has been broken.

Bug: 8191824
Change-Id: I791b514c6bec1ca634a65d9f87c5fa06da01b5ed
485dfb5ccb6d8b2c5d498ff6ee41b14e79103e3c 24-Sep-2012 Ian Rogers <irogers@google.com> Allow max free size of heap to be configured.

This allows the max free to be larger on devices with more memory and
thereby avoid GCs (that may be more frequent due to larger bitmaps).

b/6606849

Change-Id: I4063a303ea4be3c1f227259d699fb238a806451f
2f30ef57ceb02ee5d6719d2158bd9bca4723687d 29-Aug-2012 Ian Rogers <irogers@google.com> Revert "Revert "Trim pre-Zygote fork, fix under-estimate of heap limit.""

This reverts commit 4c7e27186d87ccd40646fd4f514dc982ff5b40b1.
808a7c0e7e39b7ca3c7db1366e6e4089166052bb 29-Aug-2012 Ian Rogers <irogers@google.com> Revert "Revert "Upgrade to dlmalloc 2.8.5.""

This reverts commit 729eebbb4e4ec5b826b7230b4c02267da341b70b.
4c7e27186d87ccd40646fd4f514dc982ff5b40b1 24-Aug-2012 Ian Rogers <irogers@google.com> Revert "Trim pre-Zygote fork, fix under-estimate of heap limit."

This reverts commit 2f8d5e11f735e9ee8e235c31b3f113f6c90ad63c.
2f8d5e11f735e9ee8e235c31b3f113f6c90ad63c 23-Aug-2012 Ian Rogers <irogers@google.com> Trim pre-Zygote fork, fix under-estimate of heap limit.

Card scanning uses dvmHeapSourceGetValue to scan from the heap base to
the total foot print of the heap. Trimming the Zygote may lower the
footprint of the heap by creating a hole in the middle. This hole is
unaccounted for in the card scanning leading to missed dirty cards.

This was a regression introduced by:
https://android-review.googlesource.com/#/c/41728/
as it didn't #define MORECORE_CANNOT_TRIM 1 that was previously defined
here:
https://android-review.googlesource.com/#/c/41731/4/libcutils/mspace.c

Introduce a notion of dvmHeapSourceGetLimit so that card scanning
doesn't rely on footprint. Trim the heap before forking the Zygote. This
change continues to enable morecore trimming of mspaces.

Change-Id: I3f0b12371097f50a1f920cac25846ca08685e7ed
497b25e87a51b4afd206ba7734971614d00301fb 22-Aug-2012 Brian Carlstrom <bdc@google.com> Revert "Upgrade to dlmalloc 2.8.5."

This reverts commit bba37bd191843ef29ef9c7a8839e98b73debfffa.
729eebbb4e4ec5b826b7230b4c02267da341b70b 22-Aug-2012 Brian Carlstrom <bdc@google.com> Revert "Upgrade to dlmalloc 2.8.5."

This reverts commit bba37bd191843ef29ef9c7a8839e98b73debfffa.
bba37bd191843ef29ef9c7a8839e98b73debfffa 18-Aug-2012 Ian Rogers <irogers@google.com> Upgrade to dlmalloc 2.8.5.

Switch to using dlmalloc 2.8.5. Define mspace functionality directly
using dlmalloc rather than taking from libcutils.
Remove growth limit check in tryMalloc that only checks initial growth
limit.
Implement trimming at the end of the mspace.

Depends upon: https://android-review.googlesource.com/41717

Change-Id: Ia2c6b50bdb0b0d5aae4b18deefbd1bf50dfa49d5
9487ab7fa22fc53512b344eeddc6dc866492a880 11-Jun-2012 Elliott Hughes <enh@google.com> Revert " Trim after explicit gc."

This reverts commit ea4c6e57a48e08eacbf08520c64133175e7d5da0
ea4c6e57a48e08eacbf08520c64133175e7d5da0 11-May-2012 SangWook Han <swhan@nemustech.com> Trim after explicit gc.

On Gingerbread, dvmHeapSourceTrim() is called 5 seconds
after every kind of GC. Current AOSP do trim only for
concurrent GC. That makes OOM killer too busy.

At least explicit GC need trim and in case of explicit
GC, there are no need to delay 5 seconds before trim.

Change-Id: I8fde8f773398bf20c674cfa6f686d7d745d56492
0cea134bef68f348225178dacf03716d4907bdbe 11-May-2012 SangWook Han <swhan@nemustech.com> Fix: Issue 26627: Dalvik Heap Trim timer value after GC

dvmRelativeCondWait need millisecods not seconds.

With this fix, trim will begins 5 seconds after concurrent GC

Bug: http://code.google.com/p/android/issues/detail?id=26627
Bug: 6482868
Change-Id: I3802b48e345725fb78e4ef2c999dd243ef30a138
1ae25c55391a874638f6a6366d2c8359c811b168 11-May-2012 SangWook Han <swhan@nemustech.com> Fix: Issue 26627: Dalvik Heap Trim timer value after GC

dvmRelativeCondWait need millisecods not seconds.

With this fix, trim will begins 5 seconds after concurrent GC

Bug: http://code.google.com/p/android/issues/detail?id=26627
Change-Id: I3802b48e345725fb78e4ef2c999dd243ef30a138
b74e7190e86d559712747e5cdb31a0d390b7af7d 16-Feb-2012 Iliyan Malchev <malchev@google.com> Replace malloc() followed by memset() to zero with calloc()

Bionic's calloc() is smart enough to not zero out memory if it gets that memory
from an anonyous mmap. Thus, if we use malloc for large allocations, we cause
unnecessary memory duplication by following the malloc() with a memset().

An even better approach would be to replace the known large calloc() calls with
dvmAllocRegion() allocation.

Change-Id: Id308f541c9a040d5929bf991b6c2bfdefb823c3c
c1a4ab9c313d8a3d12007f2dbef7b5a6fa4ac2ef 06-Jan-2012 Steve Block <steveblock@google.com> Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/#/c/157220

Also fix an occurrence of LOGW missed in an earlier change.

Bug: 5449033
Change-Id: I2e3b23839e6dcd09015d6402280e9300c75e3406
af6cf54652d1b27885b99e216bee29b955052630 04-Nov-2011 Andy McFadden <fadden@android.com> Reduce Dalvik card table overhead

The VM has a "growth limit" (e.g. 48MB) that is used to cap normal
apps, and a "max heap" (e.g. 128MB) that is used for apps with unusual
high-memory requirements. The Dalvik GC uses a 128:1 "card table"
that spans the entire managed heap, out to the "max heap" limit.

The table is erased during every concurrent GC. The first time
we do that post-zygote, the copy-on-write behavior causes physical
pages to be allocated. We're currently clearing out to the heap max,
not the growth limit, which means we have a bunch of physical memory
allocated for pages that will never be used.

This changes it so we only clear out to the growth limit. If the
growth limit is removed by the app, we clear out to the heap max.
On devices with a 128MB max heap, this reduces the private/dirty
usage for most apps by 640KB.

Bug 5567332

Change-Id: Iac633017c128d63b284d48016e47d40cc46df1de
92c1f6f1b4249e4e379452ee7b49f027052bf4ce 20-Oct-2011 Steve Block <steveblock@google.com> Rename (IF_)LOGV(_IF) to (IF_)ALOGV(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/#/c/143865

Bug: 5449033
Change-Id: I8bd96961e369a08e86ff78b82d90f20f42787eb1
b2714082bad44fde247920b9280c1b40c4979c3a 10-Oct-2011 Ben Cheng <bccheng@android.com> Revert "Use the card table to scan the immune region of the heap."

This reverts commit 6c355e53332502314c3d82a7afcf898d66118f27.

Conflicts are resolved in:

vm/alloc/CardTable.cpp
vm/alloc/HeapBitmap.cpp
vm/alloc/HeapInternal.h
vm/alloc/HeapSource.cpp
vm/alloc/MarkSweep.cpp

Tested with overnight monkey runs + Delaunay.

Bug: 5037417
Change-Id: I400eff8542d0bddd865ce570a479f7750c1ba484
fe9052edaf6bebbccaac5a9fb607012778d0dd74 20-Jul-2011 Jeff Brown <jeffbrown@google.com> Trim the heap when idle after concurrent GC's.
Bug: 4984352

When applied system-wide, trimming the heap can help recover
multiple megabytes worth of pages that are no longer used.
This is especially useful for applications that periodically
allocate large objects during initialization that they then
discard when running in the background.

Change-Id: Iafffd65a70ae62022f0c74f836a84a7afbe23c3c
fd31cc071c83bdbe45e6f9db41fd76375e7ac310 10-Jun-2011 Carl Shapiro <cshapiro@google.com> Do not initiate a concurrent collection if one is already running.

It is possible to cause a recursive garbage collection by writing a
program that triggers a concurrent garbage collection and initiates a
concurrent garbage collection before the garbage collection thread is
scheduled. For example

for (;;) { new byte[16 << 20]; System.gc(); }

When this condition occurs a warning is logged although such warnings
ought to be upgraded to fatal errors. With this change, when the
garbage collection thread is scheduled it first checks to see if there
is a running collection before calling down to start the collection.

Change-Id: Ia7baf5eba245bbf3fe053d3bad3f90876cad2459
0c13923b0616dc79fcfc41b63119268273bdc8be 10-Jun-2011 Carl Shapiro <cshapiro@google.com> Always grow the limit address of the a heap along with its size.

Previously, clearing the growth limit only updated the maximumSize of
the unlimited heap without updating the limit value. This caused any
operations iterated over the extent of the heap to ignore allocations
beyond the original heap size. With this change the limit is always
kept in agreement with the maximumSize.

Bug: 4539441
Change-Id: I08c8004e724549d196e1fd5d6ad22efc85b0c8d2
60fc806b679a3655c228b4093058c59941a49cfe 26-May-2011 Dan Bornstein <danfuzz@android.com> Further conservation of newlines.

Friends don't let friends end LOG() strings with newlines.

Change-Id: I5a18c766c90c4ab5f03caa6acd601d34d91beb00
d537d4840fcdf0e279b6a7c91a27306e0544aeaa 26-May-2011 Carl Shapiro <cshapiro@google.com> Eliminate the dvmHeapSourceGetPtrFlag interface.

This routine served answering questions about object addresses. While
it was private to the garbage collector, its remaining use was inside
the heap profiler. Within the heap profiler, a single path was
executed to tested a pointer for containment within the zygote. In
its place, a new function, dvmIsZygoteObject, has been added to the GC
interface superseding the only use of dvmHeapSourceGetPtrFlag.

Change-Id: I347c9adb293bd6c196bbac3765015453133dc492
7e46af2973841f63b9301e5515f8381478b806ae 12-May-2011 Carl Shapiro <cshapiro@google.com> Various code clean-ups.

* Combine definitions with initialization. This had to be foregone in
two instances where that would have otherwise caused an unused variable
warning.

* Move the HS_BOILERPLATE macro to the top of the calling function. This
macro checks that certain globals are initialized. It should be removed
after the callers become members functions of a class.

* A few cases of inconsistent function declaration styles have been brought
in line with the rest of the file. These were overlooked in a previous
clean-up.

* The unused heap source debugging macros and tracing code have been
removed.

* One stale comments has been removed and another has been updated.

Change-Id: I20bf4b78161096310b79d7dd294d7636e6bb6f48
06f120f6092185003bc9b70e06eb44866e9676f8 11-May-2011 Carl Shapiro <cshapiro@google.com> Normalize declaration style.

Change-Id: Iae4e3d22bc185060b3a0b4c080eafaa2ec824ac2
d862faa2ceae186da5518607505eb942d634ced9 28-Apr-2011 Carl Shapiro <cshapiro@google.com> Get rid of uneeded extern, enum, typedef and struct qualifiers.

Change-Id: I236c5a1553a51f82c9bc3eaaab042046c854d3b4
5cdd4a3f91d3fc25c8eeca8f58e35bb6c4e908ca 28-Apr-2011 Carl Shapiro <cshapiro@google.com> Normalize some enumerations.

This change pulls a few enumeration types to the top of their header
file alongside other types. It also eliminates the use of the now
redundant enum qualifier.

Change-Id: I6f853bed09176cde9a83faccea7a76f595f60f2b
50e5fd5984c9b0a6f0927ed5ddf13bde40e338c7 27-Apr-2011 Carl Shapiro <cshapiro@google.com> Use C++ linkage in GC headers and remove unneeded typedefs.

Some interfaces in Alloc.h had to be left with C linkage as they are
referenced by the interpreter assembler code. That dependency will be
addressed in a future commit.

Change-Id: I6b2097a2139ddf6b4b13e592710e241442e08488
1e1433e78f560a01744e870c19c162ab88df9dc1 21-Apr-2011 Carl Shapiro <cshapiro@google.com> Remove unneeded void argument list declarations.

Change-Id: Ica749f6defa890363ec531b29e25bc415dc2cbb9
f9fa8c14c7ef87b4318d606bfc5132df7b77b17c 09-Apr-2011 Carl Shapiro <cshapiro@google.com> Fix for loops and eliminate some other undesirable idioms.

Previously, we were using a non-standard C dialect which did not permit
the nicer variable scoping in loops. Now that we are using C++ in the
collector we can guarantee that feature is available. This change also
rearranges some of the surrounding code to take advantage of the more
flexible scoping rules.

Change-Id: I9be35794cc12bcbc0d5299fe387d4bc406481075
ae188c676c681e47a93ade7fdf0144099b470e03 08-Apr-2011 Carl Shapiro <cshapiro@google.com> Compile the garbage collector and heap profiler as C++.

Change-Id: I25d8fa821987a3dd6d7109d07fd42dbf2fe0e589