अगर किसी डेलिगेट को लागू करने के तरीके में ऐसे अतिरिक्त संसाधन या मेमोरी होती है जिन्हें साफ़ तौर पर
खाली किया जाना चाहिए, तो सबसे सही तरीका यह है कि लागू करने के तरीके में close() तरीका जोड़ें.
साथ ही, क्लाइंट कॉल से ऐसा करें कि डेलिगेट इंस्टेंस का इस्तेमाल बंद हो जाए. यह तरीका,
तकनीकी तौर पर एक डेलिगेट इंस्टेंस को एक से ज़्यादा इंटरप्रेटर इंस्टेंस में शेयर करने की अनुमति देता है. हालांकि,
डेलिगेट को लागू करने वाले तरीके से साफ़ तौर पर इसके साथ काम करना चाहिए.
TensorFlow Lite की डेलिगेट लागू करने पर एक नेटिव हैंडल दिखाता है.
इनहेरिट किए गए तरीके
इंटरफ़ेस से
java.io.closeable
ऐब्स्ट्रैक्ट
शून्य
close()
इंटरफ़ेस से
java.lang.AutoClosedable
ऐब्स्ट्रैक्ट
शून्य
close()
सार्वजनिक तरीके
सार्वजनिक
अमान्य
बंद करें()
डेलिगेट को बंद करता है और उससे जुड़े किसी भी संसाधन को रिलीज़ करता है.
बेस Closeable इंटरफ़ेस में बताए गए तरीके के उलट, यह तरीका जांचे गए अपवाद नहीं दिखाता है.
सार्वजनिक
ऐब्स्ट्रैक्ट
लॉन्ग
getNativeHandle()
TensorFlow Lite की डेलिगेट लागू करने पर एक नेटिव हैंडल दिखाता है.
ध्यान दें: Java Delegate, नेटिव डेलिगेट इंस्टेंस का मालिकाना हक रखता है. साथ ही, यह पक्का करना ज़रूरी है कि किसी भी InterpreterApi इंस्टेंस का इस्तेमाल किए जाने पर, यह इसका मालिकाना हक बनाए रखे.
ध्यान दें: हो सकता है कि जब तक प्रतिनिधि को किसी अनुवादक के साथ अटैच न कर दिया गया हो,
तब तक नेटिव डेलिगेट इंस्टेंस नहीं बनाया जा सकता. इसलिए, इस तरीके को तब तक कॉल नहीं किया जाना चाहिए, जब तक कि इस डेलिगेट के साथ कोई इंटरप्रेटर बनाया न जाए.
लौटाए गए प्रॉडक्ट
स्थानीय प्रतिनिधि हैंडल. C/C++ में, यह 'TfLiteOpaqueDelegate' के लिए
पॉइंटर होना चाहिए.
[[["समझने में आसान है","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|-------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|"]]