Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js): Modified version of the @tensorflow/tfjs npm page (https://www.npmjs.com/package/@tensorflow/tfjs) example
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): MacOS 16.6.1
Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
TensorFlow.js installed from (npm or script link): script link
Describe the current behavior
After loading and using a LayersModel I call model.dispose() and tf.disposeVariables() to release the tf memory. However, if I reload the model to use it again memory is leaked, at least 16k of Array data. This occurs each time around the loop.
Describe the expected behavior
I would not expect a memory leak and would expect it to behave the same as if the model was just reused.
Comparing sample 2 with sample 1 shows the "Array" objects has increased by about 16K
Steps to demonstrate model reuse with minimal memory grown
Load the page in chrome and open devtools (or do a page reload)
Click "Run Test2" button.
Garbage collect and take a memory sample.
Click "Run Test2" button again.
Garbage collect and take another memory sample.
Comparing sample 2 with sample 1 shows the "Array" objects has increased only by about 96
Other info / logs Include any logs or source code that would be helpful to
diagnose the problem. If including tracebacks, please include the full
traceback. Large logs and files should be attached.
System information
Describe the current behavior After loading and using a LayersModel I call model.dispose() and tf.disposeVariables() to release the tf memory. However, if I reload the model to use it again memory is leaked, at least 16k of Array data. This occurs each time around the loop.
Describe the expected behavior I would not expect a memory leak and would expect it to behave the same as if the model was just reused.
Standalone code to reproduce the issue The url "https://vykingsneakerkitnative.s3.eu-central-1.amazonaws.com/SteveTest/tmp/tf-leak-test.html" demonstrates the problem. Steps to demonstrate:
Steps to demonstrate model reuse with minimal memory grown
Other info / logs Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.