In order to avoid starting a separate thread to return unused memory to
the system (the thread interferes with process startup on Android,
Zygota waits for all threads to exit before fork, but this thread never
exits), try to return it right after free.
Details
Diff Detail
- Build Status
Buildable 1551 Build 1551: arc lint + arc unit
Event Timeline
lib/asan/asan_allocator.cc | ||
---|---|---|
296 | This function is only used in asan_activation.cc, but you are not adding the flag to asan_activation_flags.inc... | |
lib/sanitizer_common/sanitizer_allocator_primary64.h | ||
87 | I think this can be memory_order_relaxed. | |
486–487 | Wait, is this not always negative / underflown? | |
498 | For general sanity, check that now_ns is larger than last_release_at_ns. | |
lib/sanitizer_common/sanitizer_flag_parser.h | ||
71 ↗ | (On Diff #78951) | Just make the flag signed int, and the special "never" value - (-1). |
lib/asan/asan_activation.cc | ||
---|---|---|
116 | Deactivation is meant to reduce memory footprint. It should keep the current value of release_to_os. | |
lib/sanitizer_common/sanitizer_allocator_primary64.h | ||
498 | I meant a non-fatal check, in case the time wraps. After a closer look, perhaps it can not wrap, but it may jump around (and even back). Let's just remove the check. |
lib/asan/asan_allocator.h | ||
---|---|---|
40 | (Unimportant) Nit: Why have a signed number? | |
lib/sanitizer_common/sanitizer_common.h | ||
841 | It's not "the magic value" right now, since any negative value will accomplish this. | |
lib/sanitizer_common/sanitizer_flags.inc | ||
125 | Please mention that this only affects a 64-bit allocator. |
- Addressing comments
lib/asan/asan_allocator.h | ||
---|---|---|
40 | It seems that using negative values to represent "do not release memory" state looks a bit saner and safer than a magic value, hence signed. |
lib/sanitizer_common/sanitizer_allocator_primary64.h | ||
---|---|---|
470 | I don't think this can be a CHECK any longer. The caller does not guarantee page size granularity. |
lib/sanitizer_common/sanitizer_allocator_primary64.h | ||
---|---|---|
470 | Why so? It is called from the loop in which we collect chunks until we get more than a page size. |
LGTM
lib/sanitizer_common/sanitizer_allocator_primary64.h | ||
---|---|---|
470 | sorry, I've misread the code |
Deactivation is meant to reduce memory footprint. It should keep the current value of release_to_os.