0Pricing
Kotlin Multiplatform Academy · درس

شرح مدير الذاكرة الجديد

تعرّف إلى كيفية تعامل Kotlin/Native الحديثة مع الحالة المشتركة.

شرح مدير الذاكرة الجديد درس مجاني في Kotlin Multiplatform Academy على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Kotlin Multiplatform Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Kotlin Multiplatform Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Memory on Kotlin/Native

On iOS your shared code runs as Kotlin/Native, which manages its own memory. Knowing how it works keeps your app stable.

The Old Days Were Painful

The original model froze objects so threads could share them. That freezing rule caused confusing crashes and a lot of workarounds.

Enter the New Manager

Modern Kotlin/Native ships a new memory manager that drops the freezing rule entirely. Shared objects just work across threads now.

No More InvalidMutabilityException

You no longer hit InvalidMutabilityException when touching state from another thread. Mutable objects can cross threads freely.

It Feels Like the JVM

The new model behaves much like the JVM you know from Android. The same shared Kotlin runs with familiar semantics on both.

Garbage Collection Included

A real garbage collector reclaims unused objects automatically. You write normal Kotlin and let the runtime clean up after you.

It Is the Default Now

Recent Kotlin versions enable the new manager by default, so a fresh KMP project already uses it. No special flag needed.

Coroutines Just Work

Because state is no longer frozen, coroutines can carry mutable data across dispatchers on iOS exactly like they do on Android.

launch(Dispatchers.Default) { state.count += 1 }

Shared State Across Threads

You can read and write a normal object from several threads without freezing it first. The runtime handles the bookkeeping for you.

val cache = mutableMapOf<String, User>()

Still Mind Concurrency

The manager removes freezing, but it does not remove race conditions. Two threads writing the same field still need coordination.

Why This Matters for You

The new manager means your shared logic ports to iOS with almost no special handling. You focus on features, not memory rules.

Quick Check

A quick check on the memory manager.

Recap

You saw how the new memory manager ends freezing, adds garbage collection, and makes shared Kotlin feel JVM-like on iOS. 🎉

الأسئلة الشائعة

هل درس «شرح مدير الذاكرة الجديد» مجاني؟

نعم — نص درس «شرح مدير الذاكرة الجديد» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Kotlin Multiplatform Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Kotlin Multiplatform Academy 4 دروس في المجموع.

ماذا ستتعلم في «شرح مدير الذاكرة الجديد»؟

تعرّف إلى كيفية تعامل Kotlin/Native الحديثة مع الحالة المشتركة. تتمرن على Kotlin Multiplatform Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Kotlin Multiplatform Academy؟

لا تُشترط خبرة سابقة. Kotlin Multiplatform Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.

كم من الوقت يستغرق درس «شرح مدير الذاكرة الجديد»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Kotlin Multiplatform Academy هذا؟

نعم. كل درس في Kotlin Multiplatform Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. شرح مدير الذاكرة الجديد
  2. الخيط الرئيسي مقابل الخلفية على iOS
  3. الحالة القابلة للتغيير وظروف السباق
  4. تصحيح حالات التجمّد وانهيارات الخيوط
← العودة إلى Kotlin Multiplatform Academy