تسرّب الذاكرة في اللغات المُدارة
في هذا الدرس 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,
ThreadLocalvalues in pooled threads, unclosed resources. - Symptom: old-gen floor rises across GCs; eventually
OutOfMemoryErrorand long full GCs. - Raising
-Xmxonly delays the failure. - Fix the retention path: bound the cache, remove the reference.
تفاصيل المخطط المبدئي
عرض عملي
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.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.