aboutsummaryrefslogtreecommitdiff
path: root/libc/bionic/jemalloc_wrapper.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix allocations escaping malloc debug.Christopher Ferris2019-11-061-10/+12
| | | | | | | | | | | | | | | | | | | | | | When using a FILE object for some malloc debug functions, calling fprintf will trigger an allocation to be put in the object. The problem is that these allocations were not allocated by the malloc debug wrapper and they get freed during the fclose as if they are malloc debug allocation. In most cases, the code will detect the bad pointer and leak the memory, but it might also cause a crash. The fix is to avoid using fprintf so that no allocations are made in the object that survive and need to be freed in the fclose call. Change the MallocXmlElem.h to use a file decsriptor not a FILE object. Add new unit and system tests to detect this case. Bug: 143742907 Test: Ran unit and system tests. Test: Ran bionic unit tests. Change-Id: I524392de822a29483aa5be8f14c680e70033eba2
* Do not check tcache clear when doing a purge.Christopher Ferris2019-07-081-3/+2
| | | | | | | | | | | | On systems where the tcache is disabled, the tcache clear option will fail, and not really do a purge. Bug: 137037462 Bug: 136236080 Test: Built taimen as malloc svelte and verified the M_PURGE mallopt Test: call failed before this fix and passes afterwards. Change-Id: Ib30e5f3e083a9c6d046adff30f2aa7eacaf6df10
* Fix malloc_info missing large allocs.Christopher Ferris2019-05-031-8/+8
| | | | | | | | | | | | | | Also change the names of some of the functions to make it very obvious that the functions being called are in je code. Write new test to make sure mallinfo and malloc_info match. Bug: 131864803 Test: New unit tests pass (along with all other bionic unit tests). Change-Id: I26eda7e64f57a8c56cc8d70e3ed6a29dcb87f630 Merged-In: I26eda7e64f57a8c56cc8d70e3ed6a29dcb87f630 (cherry picked from commit 125d32cb469d8e31f656543c3ad7b82154bc1689)
* Make purging clear the current thread cache too.Christopher Ferris2019-05-011-0/+8
| | | | | | | | | | Bug: 131362671 Test: Ran bionic unit tests. Test: Wrote a test that did a purge and verified that the tcache->ncached Test: number went from 3 to 0. Also verified that mallinfo reflects the Test: cached entries being flushed. Change-Id: I64e35618fa3b523cf29bdaceedef676abe440dd3
* Refactor the malloc_info code.Christopher Ferris2019-03-071-1/+48
| | | | | | | | | | | | | | malloc_info needs to be per native allocator, but the code treated it like a global function that doesn't depend on the native memory allocator. Update malloc debug to dump the actual pointers that it has been tracking. Test: bionic-unit-tests pass. Test: malloc debug tests pass. Test: malloc hook tests pass. Change-Id: I3b0d4d748489dd84c16d16933479dc8b8d79013e Merged-In: I3b0d4d748489dd84c16d16933479dc8b8d79013e (cherry picked from commit a3656a98b10d2a4a6194a5d9705ad9c2cc5877b0)
* Make aligned_alloc match the standard.Christopher Ferris2019-03-011-0/+15
| | | | | | | | | | | | | | | | Jemalloc does not verify that the size parameter is a multiple of alignment. Fix this since it only went into P. Fix the unit tests, and fix malloc debug/malloc hooks to handle this new restrictive behavior. Bug: 126944692 Test: Ran bionic unit tests. Test: Ran bionic unit tests with malloc hooks enabled (no new tests fail). Test: Ran bionic unit tests with malloc debug enabled (no new tests fail). Test: Ran malloc debug unit tests. Change-Id: I4d50785928815679c781ca729f998454d76b9192
* Move to jemalloc5.Christopher Ferris2018-11-131-6/+13
| | | | | | | Bug: 62621531 Test: Builds and boots. All unit tests pass. Change-Id: I09d106cc3b658885b9155d6838f8df61498d3f85
* malloc: add M_PURGE mallopt flagTim Murray2018-10-221-0/+12
| | | | | | | | | | Add a new mallopt flag that purges any pending decaying pages. Test: boots and works bug 117795621 Change-Id: Ib250ae2b705b6a368c1efb801d6a7be54e075acb (cherry pciekd from commit 5083e833a650ebe510ed52603ce5c8cd4374c48e)
* Modernize codebase by replacing NULL with nullptrYi Kong2018-08-021-1/+1
| | | | | | | | Fixes -Wzero-as-null-pointer-constant warning. Test: m Bug: 68236239 Change-Id: I5b4123bc6709641315120a191e36cc57541349b2
* Add a legacy inline for mmap64.Dan Albert2017-10-051-1/+1
| | | | | | | | | | | | | While this was never an inline, this function alone has caused most of the bug reports related to _FILE_OFFSET_BITS=64. Providing an inline for it should allow a lot more code to build with _FILE_OFFSET_BITS=64 when targeting pre-L. Test: make checkbuild Test: built trivial cc_binary for LP32 against API 14 with _FILE_OFFSET_BITS=64 set Bug: lots Change-Id: I8479d34af4da358c11423bee43d45b59e9d4143e
* Add support for modifying decay timer.Christopher Ferris2017-05-151-0/+36
| | | | | | | | | | | | | | | Add the mallopt function, and only a single option so far. Bug: 36401135 Test: Built and booted bullhead. Test: Ran jemalloc unit tests. Test: Ran bionic unit tests. Test: Ran a test that allocated and free'd a large piece of memory, Test: and verified that after changing the parameter, the PSS Test: sticks around (decay timer set to 1), the PSS is purged (decay Test: timer set to 0). Change-Id: I6927929b0c539c1023d34772d9e26bb6a8a45877
* Slim down static binaries by avoiding stdio.Elliott Hughes2014-07-101-1/+1
| | | | | | | | | | | | | | It's okay for a program to choose to drag in stdio, but it's unfortunate if even the minimal "int main() { return 42; }" drags in stdio... This brings the minimal static binary on ARM down from 78KiB to 46KiB. Given that we don't have a separate -lpthread it's not obvious to me that we can shave this down any further. I'm not sure whether this is a worthwhile change for that reason. (And the fact that dynamic binaries, the usual case, are unaffected either way.) Change-Id: I02f91dcff37d14354314a30b72fed2563f431c88
* Move common macros into bionic_macros.h.Christopher Ferris2014-06-181-6/+10
| | | | | Bug: 15590152 Change-Id: I730636613ef3653f68c5ab1d43b53beaf8e0dc25
* Move jemalloc due to whole_static_library bug.Christopher Ferris2014-06-161-0/+44
Rename jemalloc.cpp to jemalloc_wrapper.cpp to avoid problems with the libc library having two jemalloc.o files that clobber each other. Change-Id: I9a2d966dbf414b1367ee0ef1f0d73fca6f25b518