diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp index 0c9ae885e85..3d69b4a84ed 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp @@ -88,6 +88,10 @@ TextMeasurement TextLayoutManager::measureCachedSpannableById( maximumSize.height, attachmentPositions)); + // Clean up allocated ref - it still takes up space in the JNI ref table even + // though it's 0 length + env->DeleteLocalRef(attachmentPositions); + // TODO: currently we do not support attachments for cached IDs - should we? auto attachments = TextMeasurement::Attachments{}; @@ -172,8 +176,10 @@ TextMeasurement TextLayoutManager::doMeasure( } } } - // DELETE REF + + // Clean up allocated ref env->DeleteLocalRef(attachmentPositions); + return TextMeasurement{size, attachments}; }