انتقل إلى المحتوى
أمين أبوزيد
درس مخطط لهMID-002-L06

تسرّب الذاكرة في اللغات المُدارة

  • الدرس 6 من 7
  • Mid-level
في هذا الدرس 4 موضوعات

هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

في هذا الدرس

recognize how leaks happen with a GC.

الموضوعات المخطط لها

  • A Java leak is an object that is still reachable but no longer needed.
  • Classic sources: unbounded caches, static collections, listeners never removed, ThreadLocal values in pooled threads, unclosed resources.
  • Symptom: old-gen floor rises across GCs; eventually OutOfMemoryError and long full GCs.
  • Raising -Xmx only delays the failure.
  • Fix the retention path: bound the cache, remove the reference.
تفاصيل المخطط المبدئي

عرض عملي

java
private static final Map<Long, Product> CACHE = new HashMap<>(); // never evicted

اختبر فهمك

Why does the GC not free the leaked entries?

أظهر الإجابة

They are still reachable through the static map.

التطبيق

طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.

المختبر والتمارين الاختبار

تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.

اكتب للبحث في المستويات والمراحل والوحدات والدروس.