संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
इस पेज पर, ऐसे इंस्टेंस को हटाने के सबसे सही तरीके बताए गए हैं जिनकी अब ज़रूरत नहीं है.
नेविगेशन सेशन पूरे होने पर Navigator#clearDestinations और Navigator#cleanup का इस्तेमाल करना
मेमोरी लीक को रोकने और सही तरीके से क्लीनअप करने के लिए, नेविगेशन सेशन पूरा होने के बाद Navigator#clearDestinations और Navigator#cleanup का इस्तेमाल करें. साथ ही, जब Navigator इंस्टेंस की ज़रूरत न हो, तब भी इनका इस्तेमाल करें. ऐसा तब किया जा सकता है, जब उपयोगकर्ता मैप से हट गया हो और उससे जुड़ी गतिविधि का onDestroy() चालू हो गया हो.
जब GoogleMap एलिमेंट की ज़रूरत न हो, तो उन्हें हटा दें
अगर आपका ऐप्लिकेशन, नेविगेशन के अलावा अन्य मैप सुविधाओं के लिए GoogleMap इंस्टेंस का इस्तेमाल करता है, तो जब इसकी ज़रूरत न हो, तब इस इंस्टेंस को हटा दें. उदाहरण के लिए, GoogleMap से जुड़े Polygon, Polyline, और Marker एलिमेंट को हटाने के लिए, Polygon#remove, Polyline#remove, और Marker#remove तरीकों को कॉल करें. इसके बाद, जब GoogleMap इंस्टेंस की ज़रूरत न हो, तो उसे खाली करने के लिए GoogleMap#clear को कॉल करें और इंस्टेंस को null को असाइन करें.
[[["समझने में आसान है","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-09-04 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eUse \u003ccode\u003eNavigator#clearDestinations\u003c/code\u003e and \u003ccode\u003eNavigator#cleanup\u003c/code\u003e when navigation sessions are completed to prevent memory leaks.\u003c/p\u003e\n"],["\u003cp\u003eClean up \u003ccode\u003eGoogleMap\u003c/code\u003e elements like Polygons, Polylines, and Markers by calling their respective \u003ccode\u003eremove\u003c/code\u003e methods when they are no longer needed.\u003c/p\u003e\n"],["\u003cp\u003eAfter a \u003ccode\u003eGoogleMap\u003c/code\u003e instance is no longer in use, call \u003ccode\u003eGoogleMap#clear\u003c/code\u003e and assign the instance to \u003ccode\u003enull\u003c/code\u003e to free up resources.\u003c/p\u003e\n"]]],[],null,["# Instance cleanup best practices\n\nThis page explains best practices for cleaning up instances after they are no\nlonger needed.\n\nUse `Navigator#clearDestinations` and `Navigator#cleanup` when navigation sessions are completed\n------------------------------------------------------------------------------------------------\n\nTo prevent memory leaks and ensure proper cleanup, use\n`Navigator#clearDestinations` and `Navigator#cleanup` after the navigation\nsession is completed and the Navigator instance is no longer needed. This can be\ndone when the user has navigated away from the map and when `onDestroy()` of the\nassociated activity is invoked.\n\nClean up `GoogleMap` elements when they are no longer needed\n------------------------------------------------------------\n\nIf your app uses a `GoogleMap` instance for non-navigation maps experiences, be\nsure to clean up this instance when it is no longer needed. For example, clean\nup the Polygon, Polyline, and Marker elements associated with `GoogleMap` by\ncalling the `Polygon#remove`, `Polyline#remove`, and `Marker#remove` methods,\nrespectively. Then, to free up the `GoogleMap` instance after it is not longer\nneeded, call `GoogleMap#clear` assign the instance to `null`.\n\nFor more information about using a `GoogleMap` instance in your app, see\n[`GoogleMap` interaction best\npractices](/maps/documentation/navigation/android-sdk/googlemap-interactions-best-practices)."]]