Increase dlmalloc's granularity to 1 << 25 (#30)

* Increase dlmalloc's granularity to 1 << 10

* Prevent trimming in dlmalloc
This commit is contained in:
Richard Shin 2016-09-29 23:46:04 -07:00 committed by Philipp Moritz
parent 227eab3b5a
commit 9c223a1e48

View file

@ -18,6 +18,7 @@ int fake_munmap(void *, size_t);
#define DIRECT_MUNMAP(a, s) fake_munmap(a, s)
#define USE_DL_PREFIX
#define HAVE_MORECORE 0
#define DEFAULT_GRANULARITY ((size_t) 1U << 25)
#include "thirdparty/dlmalloc.c"
@ -27,6 +28,7 @@ int fake_munmap(void *, size_t);
#undef DIRECT_MUNMAP
#undef USE_DL_PREFIX
#undef HAVE_MORECORE
#undef DEFAULT_GRANULARITY
struct mmap_record {
int fd;
@ -98,7 +100,11 @@ int fake_munmap(void *addr, size_t size) {
struct mmap_record *record;
HASH_FIND(hh_pointer, records_by_pointer, &addr, sizeof(addr), record);
assert(record != NULL);
if (record == NULL || record->size != size) {
/* Reject requests to munmap that don't directly match previous
* calls to mmap, to prevent dlmalloc from trimming. */
return -1;
}
close(record->fd);
HASH_DELETE(hh_fd, records_by_fd, record);