Android Memory Leak


I’ve converted my Android app from using tensorflow to pytorch and recently ran into a bug with memory growth. Below are screenshots from the android memory profiler. As you can see the Native memory grows when calling module.forward:

outputTensor = module.forward(IValue.from(inputTensor)).toTensor();

As I am a new user I cannot post the second picture but when commenting out this line, memory usage is constant.

Currently I use:
implementation ‘org.pytorch:pytorch_android:1.13.0’
implementation ‘org.pytorch:pytorch_android_torchvision:1.13.0’

I have tried w/ Vulkan backend, without, using the NNAPI and using both the lite and regular libraries. All of them appear to have this same issue.

Just wondering if anyone else has experienced something similar recently.