hiukim / mind-ar-js

Web Augmented Reality. Image Tracking, Face Tracking. Tensorflow.js
MIT License
2.22k stars 415 forks source link

Fixed memory leaks in BuildExtremas and ComputeLocalization kernels #320

Closed jmschrack closed 1 year ago

jmschrack commented 1 year ago

Added disposeIntermediateTensorInfo to BuildExtremas and ComputeLocalization kernels.

BuildExtremas is a bit odd, but I think what is happening is that tidy() is catching the original image0 and image2 tensor references. And not the ones we overwrite them with since this occurs inside of a kernel function.

hiukim commented 1 year ago

@jmschrack Why do you think there is memory leak? I did a quick check using tf.memory() and the usage statistics stay the same across time.

I guess tf.tidy does pick up the garbage left over from engine().runKernel, whereas runWebGLProgram (used in other kernels) doesn't.

jmschrack commented 1 year ago

Hmm.... it's been a too long for me to remember exactly. But I can't recreate the memory leak either. I'll close it for now, but i'll leave this branch up in my fork in case we need to revisit it.