위임 구현이 명시적으로 해제되어야 하는 추가 리소스나 메모리를 보유하는 경우 close() 메서드를 구현에 추가하고 대리자 인스턴스가 더 이상 사용되지 않을 때 클라이언트가 명시적으로 호출하도록 하는 것이 좋습니다. 이 방법을 사용하면 기술적으로 여러 인터프리터 인스턴스에서 단일 대리자 인스턴스를 공유할 수 있지만 대리자 구현에서는 이를 명시적으로 지원해야 합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-24(UTC)"],[],[],null,["# Delegate\n\npublic interface **Delegate** \n\n|---|---|---|\n| Known Indirect Subclasses [GpuDelegate](/edge/api/tflite/java/org/tensorflow/lite/gpu/GpuDelegate) |--------------------------------------------------------------------------|-----------------------------------------------------------------------------------| | [GpuDelegate](/edge/api/tflite/java/org/tensorflow/lite/gpu/GpuDelegate) | [Delegate](/edge/api/tflite/java/org/tensorflow/lite/Delegate) for GPU inference. | |||\n\nWrapper for a native TensorFlow Lite Delegate.\n\nIf a delegate implementation holds additional resources or memory that should be explicitly\nfreed, then best practice is to add a `close()` method to the implementation and have the\nclient call that explicitly when the delegate instance is no longer in use. While this approach\ntechnically allows sharing of a single delegate instance across multiple interpreter instances,\nthe delegate implementation must explicitly support this.\n\n\u003cbr /\u003e\n\n### Public Methods\n\n|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| void | [close](/edge/api/tflite/java/org/tensorflow/lite/Delegate#close())() Closes the delegate and releases any resources associated with it. |\n| abstract long | [getNativeHandle](/edge/api/tflite/java/org/tensorflow/lite/Delegate#getNativeHandle())() Returns a native handle to the TensorFlow Lite delegate implementation. |\n\n### Inherited Methods\n\nFrom interface java.io.Closeable \n\n|---------------|---------|\n| abstract void | close() |\n\nFrom interface java.lang.AutoCloseable \n\n|---------------|---------|\n| abstract void | close() |\n\nPublic Methods\n--------------\n\n#### public void\n**close**\n()\n\nCloses the delegate and releases any resources associated with it.\n\nIn contrast to the method declared in the base [Closeable](https://developer.android.com/reference/java/io/Closeable.html) interface, this method\ndoes not throw checked exceptions.\n\n\u003cbr /\u003e\n\n#### public abstract long\n**getNativeHandle**\n()\n\nReturns a native handle to the TensorFlow Lite delegate implementation.\n\nNote: The Java [Delegate](/edge/api/tflite/java/org/tensorflow/lite/Delegate) maintains ownership of the native delegate instance, and\nmust ensure its existence for the duration of usage with any [InterpreterApi](/edge/api/tflite/java/org/tensorflow/lite/InterpreterApi) instance.\n\nNote: the native delegate instance may not be created until the delegate has been attached\nto an interpreter, so this method should not be called until after an interpreter has been\nconstructed with this delegate.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n##### Returns\n\n- The native delegate handle. In C/C++, this should be a pointer to 'TfLiteOpaqueDelegate'. \n\n##### Throws\n\n| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | if called before the native delegate instance has been constructed. |\n|-------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|"]]