diff options
author | mattip <matti.picus@gmail.com> | 2017-04-07 07:54:34 +0300 |
---|---|---|
committer | mattip <matti.picus@gmail.com> | 2017-04-07 07:54:34 +0300 |
commit | 743b549eb3988a9c44b9e0277cb92fd7a7946813 (patch) | |
tree | a57913786614ffa3469bf16a4984c4dfa3cd194d | |
parent | aa746c68d092022df0952e43b29ca4abe092d03b (diff) | |
download | numpy-743b549eb3988a9c44b9e0277cb92fd7a7946813.tar.gz |
COMPAT: notify garbage collector when memory is allocated
-rw-r--r-- | numpy/core/src/multiarray/alloc.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/alloc.c b/numpy/core/src/multiarray/alloc.c index b5d437d3e..e5690ae4b 100644 --- a/numpy/core/src/multiarray/alloc.c +++ b/numpy/core/src/multiarray/alloc.c @@ -39,7 +39,19 @@ _npy_alloc_cache(npy_uintp nelem, npy_uintp esz, npy_uint msz, return cache[nelem].ptrs[--(cache[nelem].available)]; } } - return alloc(nelem * esz); +#ifdef _PyPyGC_AddMemoryPressure + { + size_t size = nelem * esz; + void * ret = alloc(size); + if (ret != NULL) + { + _PyPyPyGC_AddMemoryPressure(size); + } + return ret; + } +#else + return alloc(nelem * esz); +#endif } /* |