2221
GB
What is a 'memory leak' in a managed language like Java and why is it still possible despite garbage collection?
IN
जावा जैसी प्रबंधित भाषा में 'मेमोरी लीक' क्या है और कचरा संग्रहण के बावजूद यह अभी भी क्यों संभव है?
A
Memory leaks cannot occur in managed languages
प्रबंधित भाषाओं में मेमोरी लीक नहीं हो सकती
B
A logical memory leak occurs when objects are still referenced (preventing GC) but no longer needed — common causes: static collections holding objects, event handlers not unregistered, and caches without eviction policies
एक तार्किक मेमोरी रिसाव तब होता है जब ऑब्जेक्ट अभी भी संदर्भित होते हैं (जीसी को रोकते हैं) लेकिन अब इसकी आवश्यकता नहीं है - सामान्य कारण: ऑब्जेक्ट रखने वाले स्थिर संग्रह, अपंजीकृत नहीं होने वाले ईवेंट हैंडलर, और निष्कासन नीतियों के बिना कैश
C
Only occur when using native interop calls (P/Invoke, JNI)
केवल देशी इंटरऑप कॉल (पी/इनवोक, जेएनआई) का उपयोग करते समय होता है
D
Modern JVMs completely eliminate all forms of memory leaks
आधुनिक जेवीएम सभी प्रकार की मेमोरी लीक को पूरी तरह से समाप्त कर देते हैं
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English)
Garbage collection collects objects with no reachable references. A 'logical leak' means the application holds a reference it doesn't need. Classic example: adding event handlers to a long-lived object without removing them keeps the subscriber alive for the publisher's lifetime.
व्याख्या (हिन्दी)
कचरा संग्रहण उन वस्तुओं को एकत्रित करता है जिनका कोई पहुंच योग्य संदर्भ नहीं है। 'लॉजिकल लीक' का मतलब है कि एप्लिकेशन के पास ऐसा संदर्भ है जिसकी उसे आवश्यकता नहीं है। उत्कृष्ट उदाहरण: ईवेंट हैंडलर को लंबे समय तक मौजूद ऑब्जेक्ट में हटाए बिना जोड़ने से सब्सक्राइबर प्रकाशक के जीवनकाल तक जीवित रहता है।