Skip to content

Instantly share code, notes, and snippets.

@pitrou
Created March 10, 2016 14:06
Show Gist options
  • Save pitrou/bada94f31e1c8891585c to your computer and use it in GitHub Desktop.
Save pitrou/bada94f31e1c8891585c to your computer and use it in GitHub Desktop.
import gc
import sys
import numpy as np
from numba import jit
def inner():
N = 100
a = np.ones(N)
for i in range(1000):
if i % 100 == 0:
gc.collect()
print("%d ... %d allocated blocks" % (i, sys.getallocatedblocks()))
@jit(nopython=True, nogil=True)
def testNumba(x):
return np.sum(x)
r = testNumba(a)
assert r == N, r
def main():
inner()
gc.collect()
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment