php-opencv / php-opencv-examples

Tutorial for computer vision and machine learning in PHP 7/8 by opencv (installation + examples + documentation)
478 stars 92 forks source link

Any insight on memory usage? #32

Open chadpriddle opened 4 months ago

chadpriddle commented 4 months ago

Digital Ocean server 1 Intel vCPU and 2GB of memory with Ubuntu 24.04, Apache2, PHP 8.3

Brand new server and messing around with this library. The server idles about 30-40% of memory with no users/activity.

If I process an object detection function for one image it jumps about 5-10%

If I process 5 images in a row in one function it hits 90% memory usage then the server is bogged down for quite some time (30-60 minutes) until the memory comes back down. CPU is normal, spikes up and then back down after the process ends, as you'd expect.

While I know I have wimpy sever specs for testing, I'm wondering if there is a memory leak, is there a function to tell opencv to release the memory usage after it processes an image?

At the time of writing this the memory is at 92% after processing 5 images. Reboot the server, let it idle for about 10 minutes and the memory is back down to 34%.

Any insight would be helpful. Thanks