double-checked locking for speed up
@@ -458,6 +458,7 @@ cdef class SingleDeviceMemoryPool:
# find best-fit, or a smallest larger allocation
length = len(self._free)
for i in range(index, length):
+ if self._free[i]:
try:
rlock.lock_fastrlock(self._free_lock, -1, True)
free_list = self._free[i]
