(self, size=mmap.PAGESIZE)
| 121 | _DOUBLE_ARENA_SIZE_UNTIL = 4 * 1024 ** 2 |
| 122 | |
| 123 | def __init__(self, size=mmap.PAGESIZE): |
| 124 | self._lastpid = os.getpid() |
| 125 | self._lock = threading.Lock() |
| 126 | # Current arena allocation size |
| 127 | self._size = size |
| 128 | # A sorted list of available block sizes in arenas |
| 129 | self._lengths = [] |
| 130 | |
| 131 | # Free block management: |
| 132 | # - map each block size to a list of `(Arena, start, stop)` blocks |
| 133 | self._len_to_seq = {} |
| 134 | # - map `(Arena, start)` tuple to the `(Arena, start, stop)` block |
| 135 | # starting at that offset |
| 136 | self._start_to_block = {} |
| 137 | # - map `(Arena, stop)` tuple to the `(Arena, start, stop)` block |
| 138 | # ending at that offset |
| 139 | self._stop_to_block = {} |
| 140 | |
| 141 | # Map arenas to their `(Arena, start, stop)` blocks in use |
| 142 | self._allocated_blocks = defaultdict(set) |
| 143 | self._arenas = [] |
| 144 | |
| 145 | # List of pending blocks to free - see comment in free() below |
| 146 | self._pending_free_blocks = [] |
| 147 | |
| 148 | # Statistics |
| 149 | self._n_mallocs = 0 |
| 150 | self._n_frees = 0 |
| 151 | |
| 152 | @staticmethod |
| 153 | def _roundup(n, alignment): |
no test coverage detected