mirror of
https://github.com/vale981/ray
synced 2025-03-06 10:31:39 -05:00
Increase dlmalloc's granularity to 1 << 25 (#30)
* Increase dlmalloc's granularity to 1 << 10 * Prevent trimming in dlmalloc
This commit is contained in:
parent
227eab3b5a
commit
9c223a1e48
1 changed files with 7 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue