Збирач сміття (Garbage Collector, GC) є ключовим компонентом платформи .NET, що забезпечує автоматичне керування пам'яттю та запобігає витокам. У версії .NET 9, випущеній у листопаді 2024 року, відбулися значні покращення GC, спрямовані на підвищення ефективності пам'яті, зниження латентності та адаптацію до динамічних навантажень. Основними інноваціями є активація за замовчуванням механізму DATAS (Dynamic Adaptation to Application Sizes), адаптивний Server GC та оптимізації, пов'язані з JIT-компіляцією. Ця оглядова стаття аналізує ці зміни, їх механізми, вплив на продуктивність та рекомендації щодо використання. На основі офіційної документації Microsoft та бенчмарків, демонструється зниження споживання пам'яті на 93% та зростання throughput на 15% у типових сценаріях. Стаття корисна для розробників, які працюють з високонавантаженими додатками, особливо в хмарних та контейнеризованих середовища
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MainActivity.java: | |
| package site.sunmeat.services; | |
| import android.app.ActivityManager; | |
| import android.app.AlarmManager; | |
| import android.app.PendingIntent; | |
| import android.content.BroadcastReceiver; | |
| import android.content.Context; | |
| import android.content.Intent; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MainActivity.java: | |
| package site.sunmeat.helloworld; | |
| import android.os.Bundle; | |
| import androidx.annotation.NonNull; | |
| import androidx.appcompat.app.AppCompatActivity; | |
| import com.airbnb.lottie.*; | |
| import android.animation.Animator; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MainActivity.java: | |
| package site.sunmeat.helloworld; | |
| import android.animation.AnimatorSet; | |
| import android.animation.ObjectAnimator; | |
| import android.os.Bundle; | |
| import android.view.animation.AccelerateDecelerateInterpolator; | |
| import android.widget.TextView; | |
| import androidx.appcompat.app.AppCompatActivity; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MainActivity.java: | |
| package site.sunmeat.animation; | |
| import android.content.Intent; | |
| import android.content.res.ColorStateList; | |
| import android.os.Bundle; | |
| import android.view.View; | |
| import android.view.animation.OvershootInterpolator; | |
| import android.widget.Button; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MainActivity.java: | |
| package site.sunmeat.opengles3d; | |
| import android.app.Activity; | |
| import android.opengl.GLSurfaceView; | |
| import android.os.Bundle; | |
| import android.opengl.GLES20; | |
| import android.opengl.Matrix; | |
| import javax.microedition.khronos.egl.EGLConfig; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MainActivity.java: | |
| package site.sunmeat.fonts; | |
| import android.graphics.Typeface; | |
| import android.os.*; | |
| import androidx.appcompat.app.AppCompatActivity; | |
| import androidx.core.content.res.ResourcesCompat; | |
| import androidx.core.provider.*; | |
| import android.widget.TextView; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Org.BouncyCastle.Asn1.Cmp; | |
| using System; | |
| using System.IO; | |
| using System.Reflection.Metadata; | |
| using System.Text; | |
| namespace DisposableExample | |
| { | |
| // IDisposable - інтерфейс для детермінованої очистки ресурсів у .NET. | |
| // реалізується методом Dispose(), який викликає користувач для негайного звільнення ресурсів. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Text; | |
| using System.IO; | |
| namespace FinalizeExample | |
| { | |
| // фіналізація - механізм .net для автоматичного очищення некерованих ресурсів об'єкта під час GC. | |
| // це перевизначення методу finalize() класу object, яке реалізується через деструктор ~class(). | |
| // навіщо: гарантує, що ресурси (файли, дескриптори, пам'ять) звільняються навіть якщо розробник забув викликати Dispose(). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Text; | |
| namespace GCExample | |
| { | |
| class Person | |
| { | |
| public string Name { get; set; } | |
| public string Surname { get; set; } | |
| public byte Age { get; set; } |
NewerOlder