aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2015-08-12 10:26:54 -0700
committerJason Evans <jasone@canonware.com>2015-08-12 10:26:54 -0700
commit03bf5b67be92db3a49f81816dccb5c18c0f2a0c0 (patch)
treebb4c97d3e97a4573a9728baa33d4dad199b8563f /src
parent1f27abc1b1f3583d9c6f999374613dc5319aeb12 (diff)
downloadjemalloc-03bf5b67be92db3a49f81816dccb5c18c0f2a0c0.tar.gz
Try to decommit new chunks.
Always leave decommit disabled on non-Windows systems.
Diffstat (limited to 'src')
-rw-r--r--src/chunk_dss.c3
-rw-r--r--src/chunk_mmap.c6
-rw-r--r--src/pages.c8
3 files changed, 13 insertions, 4 deletions
diff --git a/src/chunk_dss.c b/src/chunk_dss.c
index 1035581..de0546d 100644
--- a/src/chunk_dss.c
+++ b/src/chunk_dss.c
@@ -145,7 +145,8 @@ chunk_alloc_dss(arena_t *arena, void *new_addr, size_t size, size_t alignment,
ret, size);
memset(ret, 0, size);
}
- *commit = true;
+ if (!*commit)
+ *commit = pages_decommit(ret, size);
return (ret);
}
} while (dss_prev != (void *)-1);
diff --git a/src/chunk_mmap.c b/src/chunk_mmap.c
index a91a14c..36eb075 100644
--- a/src/chunk_mmap.c
+++ b/src/chunk_mmap.c
@@ -24,7 +24,8 @@ chunk_alloc_mmap_slow(size_t size, size_t alignment, bool *zero, bool *commit)
assert(ret != NULL);
*zero = true;
- *commit = true;
+ if (!*commit)
+ *commit = pages_decommit(ret, size);
return (ret);
}
@@ -61,7 +62,8 @@ chunk_alloc_mmap(size_t size, size_t alignment, bool *zero, bool *commit)
assert(ret != NULL);
*zero = true;
- *commit = true;
+ if (!*commit)
+ *commit = pages_decommit(ret, size);
return (ret);
}
diff --git a/src/pages.c b/src/pages.c
index 6f775dc..83a167f 100644
--- a/src/pages.c
+++ b/src/pages.c
@@ -102,7 +102,13 @@ pages_commit_impl(void *addr, size_t size, bool commit)
{
#ifndef _WIN32
- if (config_debug) {
+ /*
+ * The following decommit/commit implementation is functional, but
+ * always disabled because it doesn't add value beyong improved
+ * debugging (at the cost of extra system calls) on systems that
+ * overcommit.
+ */
+ if (false) {
int prot = commit ? (PROT_READ | PROT_WRITE) : PROT_NONE;
void *result = mmap(addr, size, prot, MAP_PRIVATE | MAP_ANON |
MAP_FIXED, -1, 0);