Ensure that the device pointer we get from getConnectedDevicePointer
is released when no longer used
#21539
Labels
getConnectedDevicePointer
is released when no longer used
#21539
Problem
With #21256 we are introducing a memory leak. The leak was allowed to be introduced since that PR fixes a use after free that is arguably worse then the memory leak. The PR was large enough without refactoring the java side hence creating this PR so that the memory leak could be addressed separately afterwards
Proposed Solution
When onDeviceConnected gives a pointer to the Java side. We wrap the pointer in an object that has a desctructor that calls a JNI to do a free on that pointer provided. This would need all downstream consumers that previously passed a long the pointer to now use the wrapper object.
The text was updated successfully, but these errors were encountered: