Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
on macOS, anonymous paging cases can be tracked via tooling as vmmap.
9 changes: 9 additions & 0 deletions Modules/mmapmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ my_getallocationgranularity (void)
#include <sys/mman.h>
#include <sys/stat.h>

#ifdef __APPLE__
#include <mach/vm_statistics.h>
# define MAP_ANON_ID 244
#endif

#if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
static int
my_getpagesize(void)
Expand Down Expand Up @@ -1212,6 +1217,10 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
#ifdef MAP_ANONYMOUS
/* BSD way to map anonymous memory */
flags |= MAP_ANONYMOUS;
#ifdef __APPLE__
/* Darwin allows to tag anonymous memory */
fd = VM_MAKE_TAG(MAP_ANON_ID);
#endif

/* VxWorks only supports MAP_ANONYMOUS with MAP_PRIVATE flag */
#ifdef __VXWORKS__
Expand Down