Ask Your Question

Revision history [back]

Problem Solved. Because of the numpy memory allocation, excessive memory usage do not directly get free from system 's virtual memory.

The Solution is simple :). Instead of creating and destroying new memory in loop, we use in-memory API.

The following code have stable memory usage pattern.

def main():
    M = np.random.randn(3,3)
    img = np.random.randint(255, size=(4096, 4096, 3))
    img = np.uint8(img)
    rot = np.zeros_like(img)
    while(1):
        cv2.warpPerspective(img, M, (4096, 4096), dst=rot)
        time.sleep(1)