Chapterبەش 1 · Lectureوانە 1.4
Memory While a Program Runs: Stack, Heap and Garbage Collectionبیرگە لە کاتی کارکردنی بەرنامەدا: ستاکی بانگکردن، هیپی بیرگە و فڕێدانی بەجێماوەکان
Where a running program keeps its data: the call stack with one frame per call, the heap for values that live longer, and the references and pointers that lead to them; what garbage is; freeing memory by hand and its three classic bugs (leaks, dangling pointers, double frees); and automatic garbage collection: reference counting and its cycle problem, mark and sweep, generations, what Python, Java, JavaScript, Dart, PHP, Swift, C, C++ and Rust do in 2026, and the leaks that still happen with a collector.
کارا لە کوێ هەڵدەگرێت: بە چوارچێوەیەک بۆ هەر بانگکردنێک، بۆ ئەو نرخانەی زیاتر دەمێننەوە و ئەو و دەیانگەیەننە لایان؛ بەجێماو چییە؛ ئازادکردنەوەی بە دەست و سێ کلاسیکییەکەی (، ، )؛ و خۆکار: و کێشەی بازنەکان، ، نەوەکان، ئەوەی Python، Java، JavaScript، Dart، PHP، Swift، C، C++ و Rust لە 2026دا دەیکەن و ئەو حاڵەتانەی کە لەگەڵ سیستەمی ڕوو دەدەن.
What you will learnچی فێر دەبیت
- Explain what the call stack and the heap hold, and why a value that must outlive a call goes on the heap.
- Say in plain words what a reference and a pointer are, and when an object becomes garbage.
- Describe manual memory management and recognise a memory leak, a dangling pointer and a double free in pseudocode.
- Trace reference counting and mark and sweep on a small example, including a reference cycle.
- Compare how popular languages free memory in 2026, and avoid the leaks that happen even with a garbage collector.
- ڕوونی بکەیتەوە و چی هەڵدەگرن و بۆچی نرخێک کە دەبێت لە بانگکردنێک زیاتر بمێنێت دەچێتە .
- بە زمانێکی سادە بڵێیت و چین و کەی دەبێت بە بەجێماو.
- بەڕێوەبردنی دەستیی وەسف بکەیت و ، و لە بناسیتەوە.
- و لەسەر نموونەیەکی بچووک هەنگاو بە هەنگاو جێبەجێ بکەیت، لەگەڵ .
- بەراوردی ئەوە بکەیت کە زمانە باوەکان لە 2026دا چۆن ئازاد دەکەنەوە و خۆت لە بپارێزیت، تەنانەت لەگەڵ سیستەمی .
Where does a running program keep things?بەرنامەیەکی کارا شتەکانی لە کوێ هەڵدەگرێت؟
When you start a program, the operating system loads its instructions into RAM and gives it memory for its data. Every number the program calculates, every list of names and every picture it opens must sit somewhere in that memory while the program runs, and the space must be given back when it is no longer needed. This lesson shows how that works, whatever language you use.
کاتێک دەکەیتەوە، بار دەکاتە ناو RAM و بەشێک لە بۆ دەداتێ. هەر ژمارەیەک حیسابی دەکات، هەر لیستێکی ناو و هەر وێنەیەک کە دەیکاتەوە، دەبێت لە کاتی کارکردندا لە شوێنێکی ئەو بێت و کاتێک ئیتر پێویست نەما، شوێنەکەی دەبێت بگەڕێنرێتەوە. ئەم وانەیە پیشانت دەدات ئەمە چۆن کار دەکات، هەر زمانێک بەکار بهێنیت.
A running program divides its memory into a few areas. Two matter most to a programmer: the call stack, a neat pile of small boxes for the function calls that are running now, and the heap, a large area for everything that must live longer. The picture is a simplified map; real systems add more detail, but every language uses these two ideas.
کارا دابەش دەکات بۆ چەند ناوچەیەک. دوانیان بۆ بەرنامەساز گرنگترینن: ، کۆمەڵە سندوقێکی بچووکی ڕێک بۆ هەر کە ئێستا کار دەکات و ، ناوچەیەکی گەورە بۆ هەموو ئەو شتانەی دەبێت ماوەیەکی درێژتر بمێننەوە. وێنەکە نەخشەیەکی سادەکراوە؛ سیستەمە ڕاستەقینەکان وردەکاریی زیاتریان هەیە، بەڵام هەموو زمانێک ئەم دوو بیرۆکەیە بەکار دەهێنێت.
The call stack: one frame per callستاکی بانگکردن: بۆ هەر بانگکردنێک چوارچێوەیەک
Each time a function is called, the program puts a new frame on top of the call stack. The frame holds the function's parameters, its local variables and the place to go back to when it finishes. When the function returns, its frame is taken off, and its variables disappear with it. Follow this bakery program: the main part calls bill, and bill calls discount.
هەر جارێک بانگ دەکرێت، چوارچێوەیەکی نوێ دەخاتە سەر . چوارچێوەکە ، و ئەو شوێنەی کە دوای تەواوبوون دەبێت بۆی بگەڕێتەوە هەڵدەگرێت. کاتێک دەگەڕێتەوە، چوارچێوەکەی لادەبرێت و ناویشی لەگەڵیدا نامێنن. سەیری ئەم نانەواخانە بکە: بەشی سەرەکی بانگی bill دەکات و bill بانگی discount دەکات.
FUNCTION discount(total)
off ← total × 10 ÷ 100
RETURN total − off
END FUNCTION
FUNCTION bill(count, price)
total ← count × price
IF count > 10 THEN
total ← discount(total)
END IF
RETURN total
END FUNCTION
START
loaves ← 12
toPay ← bill(loaves, 250)
OUTPUT toPay
END2700
Explain the codeڕوونکردنەوەی کۆدەکە
- Lineدێڕی 16
The call puts a frame for
billon the stack, withcount= 12 andprice= 250.بانگکردنەکە چوارچێوەیەک بۆ
billدەخاتە سەر ، کەcount= 12 وprice= 250ـی تێدایە.- Lineدێڕی 9
12 loaves are more than 10, so
billcallsdiscount: a third frame goes on top.12 نان لە 10 زیاترە، بۆیە
billبانگیdiscountدەکات: چوارچێوەی سێیەم دەچێتە سەرەوە.- Lineدێڕی 3
RETURNtakes the frame ofdiscountoff; itsoffis gone, andbillgoes on with 2700.RETURNچوارچێوەیdiscountلادەبات؛offـەکەی نامێنێت وbillبە 2700 بەردەوام دەبێت.
The call stack: one frame per callستاکی بانگکردن: بۆ هەر بانگکردنێک چوارچێوەیەک
Why the stack is fast, and its limitبۆچی ستاکی بانگکردن خێرایە و سنوورەکەی
- Fast and automatic. Making room only moves the top of the stack. Nobody searches for free space, and nothing is freed by hand: a frame disappears when its call ends.
- Known sizes. The size of a frame is known when the function is called, so the stack suits values of a fixed size, such as a number.
- Short lives. A local variable lives only while its call runs; after the return it is gone.
- Small. The stack is much smaller than the heap. Too many waiting calls, usually a function that keeps calling itself, fill it up: a , which stops the program.
- خێرا و خۆکار. شوێنکردنەوە تەنیا سەری دەجووڵێنێت. کەس بە دوای شوێنی ئازاددا ناگەڕێت و هیچ شتێک بە دەست ئازاد ناکرێتەوە: چوارچێوەیەک کاتێک بانگکردنەکەی تەواو دەبێت نامێنێت.
- قەبارەی زانراو. قەبارەی چوارچێوەیەک کاتی بانگکردنی دەزانرێت، بۆیە بۆ ئەو نرخانە گونجاوە کە قەبارەیان جێگیرە، وەک ژمارەیەک.
- تەمەنی کورت. تەنیا تا بانگکردنەکەی کار دەکات دەژی؛ دوای گەڕانەوە نامێنێت.
- بچووک. زۆر لە بچووکترە. بانگکردنی چاوەڕوانی زۆر، زۆرجار کە بێ وەستان بانگی خۆی دەکاتەوە، پڕی دەکەن: ، کە دەوەستێنێت.
The heap: room for things that live longerهیپی بیرگە: شوێن بۆ ئەو شتانەی زیاتر دەمێننەوە
Some values must outlive the call that made them, or have a size that nobody knows in advance: a class list that grows, a photo, a chat history. They go to the heap. The program asks for a piece of the heap, which is called memory allocation, and gets back where that piece is. The piece stays reserved until it is freed, not when a function ends.
هەندێک نرخ دەبێت لەو بانگکردنە زیاتر بمێنن کە دروستی کردوون، یان قەبارەیەکیان هەیە کە کەس پێشوەخت نایزانێت: لیستی پۆلێک کە گەورە دەبێت، وێنەیەک، مێژووی چاتێک. ئەمانە دەچنە . پارچەیەک لە داوا دەکات، کە پێی دەوترێت و شوێنی ئەو پارچەیە وەردەگرێتەوە. پارچەکە تا ئازاد دەکرێتەوە بۆی دەمێنێتەوە، نەک تا تەواو دەبێت.
In an old bazaar khan, a trader rents a storeroom and gets a receipt with the room number. The goods stay in the room for as long as the room is rented, wherever the trader goes. The receipt does not hold the goods; it tells you where they are. When the trader gives the room back, the khan can rent it to someone else.
لە خانێکی کۆنی بازاڕدا، بازرگانێک کۆگایەک بە کرێ دەگرێت و پسوولەیەک بە ژمارەی ژوورەکەوە وەردەگرێت. کاڵاکان تا ژوورەکە بە کرێ گیرابێت تێیدا دەمێننەوە، بازرگانەکە بچێتە هەر کوێیەک. پسوولەکە کاڵاکان هەڵناگرێت؛ پێت دەڵێت لە کوێن. کاتێک بازرگانەکە ژوورەکە دەگەڕێنێتەوە، خانەکە دەتوانێت بیداتە کەسێکی تر.
Where the analogy stops workingسنووری ئەم نموونەیە
A khan keeps a written list of rented rooms. A program's heap must also keep track of which pieces are free, and that bookkeeping costs time, which the stack does not need.
خان لیستێکی نووسراوی ژوورە بە کرێدراوەکانی هەیە. دەبێت بزانێت کام پارچانە بەتاڵن و ئەم ژمێریارییە کاتی دەوێت، کە پێویستی پێی نییە.
The heap: room for things that live longerهیپی بیرگە: شوێن بۆ ئەو شتانەی زیاتر دەمێننەوە
Example: a list that outlives its functionنموونە: لیستێک کە لە کردارەکەی زیاتر دەمێنێت
makeClass builds a list of students and returns it. Watch what happens to the frame and to the list.
makeClass لیستێکی خوێندکاران دروست دەکات و دەیگەڕێنێتەوە. سەیر بکە چی بەسەر چوارچێوەکە و لیستەکە دێت.
FUNCTION makeClass()
names ← NEW LIST
ADD "Aram" TO names
ADD "Shilan" TO names
RETURN names
END FUNCTION
START
myClass ← makeClass()
OUTPUT LENGTH(myClass)
END2
Explain the codeڕوونکردنەوەی کۆدەکە
- Lineدێڕی 2
NEW LISTmakes the list on the heap.names, in the frame ofmakeClass, only holds where the list is.NEW LISTلیستەکە لە دروست دەکات.namesلە چوارچێوەیmakeClassـدا تەنیا شوێنی لیستەکە هەڵدەگرێت.- Lineدێڕی 5
Only that reference is returned. The frame of
makeClassis taken off the stack, but the list stays on the heap.تەنیا ئەو دەگەڕێنرێتەوە. چوارچێوەی
makeClassلە لادەبرێت، بەڵام لیستەکە لە دەمێنێتەوە.- Lineدێڕی 9
myClassin the main frame now refers to the same list.ئێستا
myClassلە چوارچێوەی بەشی سەرەکیدا ئاماژە بە هەمان لیست دەکات.
Each language decides the details. In Java, a local int sits inside the frame while every object and array is on the heap; in Python every value, even a number, is an object on the heap, and frames hold only references to them.
هەر زمانێک وردەکارییەکان خۆی دیاری دەکات. لە Javaـدا intـێکی ناوخۆیی لە ناو چوارچێوەکەدایە، بەڵام هەموو و لە ؛ لە Pythonـدا هەموو نرخێک، تەنانەت ژمارەیەکیش، لە و چوارچێوەکان تەنیا بۆ ئەوان هەڵدەگرن.
References and pointers in plain wordsئاماژەکان و ئاماژەدەرەکان بە زمانێکی سادە
A variable in a frame cannot hold a whole list from the heap. It holds where the list is: its address, a number for a place in memory (memory addresses). When a language lets you see that address and even calculate with it, the variable is a pointer, as in C and C++. Most other languages give you a reference instead: it leads to the object, but the language hides the address and checks how you use it.
لە ناو چوارچێوەیەکدا ناتوانێت هەموو لیستێکی هەڵبگرێت. ئەوەی هەڵدەگرێت شوێنی لیستەکەیە: ، ژمارەیەک بۆ شوێنێک لە (ناونیشانەکانی بیرگە). کاتێک زمانێک ڕێگەت دەدات ئەو ناونیشانە ببینیت و تەنانەت حیسابی پێ بکەیت، ، وەک لە C و C++ـدا. زۆربەی زمانەکانی تر لە جیاتی ئەوە دەدەن: دەتباتە لای ، بەڵام زمانەکە ناونیشانەکە دەشارێتەوە و چاودێریی ئەوە دەکات چۆن بەکاری دەهێنیت.
Two variables can refer to the same object. A change made through one is then seen through the other, because there is only one object: see Two names, one list and Two variables, one object. A reference to nothing is null (Python writes None).
دوو دەتوانن ئاماژە بە هەمان بکەن. ئەو کاتە گۆڕانکارییەک لە ڕێگەی یەکێکیانەوە لە ئەویتریشدا دەبینرێت، چونکە تەنیا یەک هەیە: سەیری دوو ناو، یەک لیست و دوو گۆڕاو، یەک ئۆبجێکت بکە. بۆ هیچ شتێک (Python دەینووسێت None).
What is garbage?بەجێماو چییە؟
An object is garbage when the program can no longer reach it: no variable and no living object refers to it, directly or through a chain of references. The program can never use it again, but it still takes up room on the heap until something frees it.
بەجێماوە کاتێک ئیتر ناتوانێت پێی بگات: هیچ و هیچ زیندوو ئاماژەی پێ ناکات، نە ڕاستەوخۆ و نە بە زنجیرەیەک . هەرگیز ناتوانێت دووپاتە بەکاری بهێنێتەوە، بەڵام تا شتێک ئازادی دەکاتەوە هێشتا شوێن لە دەگرێت.
basket ← NEW LIST
ADD "apples" TO basket
basket ← NEW LIST
ADD "grapes" TO basketExplain the codeڕوونکردنەوەی کۆدەکە
- Lineدێڕی 3
basketnow refers to a new list. Nothing refers to the list with apples any more: it is garbage.ئێستا
basketئاماژە بە لیستێکی نوێ دەکات. ئیتر هیچ شتێک ئاماژە بە لیستی سێوەکان ناکات: بووە بە بەجێماو.
Where does the search for living objects start? At the roots: the variables in every frame on the call stack, the global variables and a few references the system keeps for itself. An object that can be reached from a root by following references is alive; everything else is garbage.
گەڕان بە دوای زیندوودا لە کوێوە دەست پێ دەکات؟ لە : هەموو چوارچێوەیەکی سەر ، و چەند تر کە سیستەمەکە بۆ خۆی ڕایاندەگرێت. کە بە شوێنکەوتنی لە پێی بگەیت زیندووە؛ هەموو شتەکانی تر بەجێماون.
Freeing memory by handئازادکردنەوەی بیرگە بە دەست
In C, and in older C++, the programmer does both jobs: asks for heap memory and gives it back. C's malloc asks for a number of bytes and returns a pointer; free gives the memory back. In pseudocode:
لە Cـدا و لە C++ـی کۆندا، بەرنامەساز هەردوو کارەکە دەکات: داوا دەکات و دەیگەڕێنێتەوە. mallocـی C ژمارەیەک داوا دەکات و دەگەڕێنێتەوە؛ free دەگەڕێنێتەوە. بە :
p ← ALLOCATE(100) // in C: p = malloc(100);
WRITE "Salam" AT p
OUTPUT TEXT AT p
FREE(p) // in C: free(p);Salam
Explain the codeڕوونکردنەوەی کۆدەکە
- Lineدێڕی 1
100 bytes of the heap are reserved;
pgets their address.100 لە تەرخان دەکرێت؛
pناونیشانەکەیان وەردەگرێت.- Lineدێڕی 4
The 100 bytes go back to the heap and can be given to the next request.
100 دەگەڕێنەوە بۆ و دەتوانرێت بدرێنە داواکاریی داهاتوو.
This gives full control: memory is freed exactly when you say, with no surprise pauses, which is why operating systems and small devices are often written this way. The price: every allocation must be freed exactly once, at the right time, and people make mistakes.
ئەمە کۆنترۆڵی تەواو دەدات: ڕێک ئەو کاتە ئازاد دەکرێتەوە کە تۆ دەڵێیت، بێ وەستانی چاوەڕواننەکراو، بۆیە و ئامێرە بچووکەکان زۆرجار بەم شێوەیە دەنووسرێن. نرخەکەی: هەر دەبێت ڕێک یەک جار و لە کاتی خۆیدا ئازاد بکرێتەوە و مرۆڤ هەڵە دەکات.
Freeing memory by handئازادکردنەوەی بیرگە بە دەست
Three classic mistakesسێ هەڵەی کلاسیکی
Back at the khan: a trader can forget to give a room back, give it back but keep using the old receipt, or give the same room back twice. Programs make the same three mistakes:
با بگەڕێینەوە بۆ خانەکە: بازرگانێک دەتوانێت گەڕاندنەوەی ژوورێک لەبیر بکات، بیگەڕێنێتەوە بەڵام هێشتا پسوولە کۆنەکە بەکار بهێنێت، یان هەمان ژوور دوو جار بگەڕێنێتەوە. هەمان سێ هەڵە دەکەن:
- : memory that is never freed. The program's memory use grows until it slows down or stops; a server that runs for months is hit hardest.
- : a pointer used after
FREE. The memory may already belong to something else, so the program reads wrong data, crashes or overwrites another value. - : the same memory freed twice. The heap's list of free places breaks, and one place can later be handed out to two owners.
- : کە هەرگیز ئازاد ناکرێتەوە. بەکارهێنانی زیاد دەبێت تا خاو دەبێت یان دەوەستێت؛ کە مانگەها کار دەکات زۆرتر زیانی پێ دەگات.
- : کە دوای
FREEبەکار دێت. لەوانەیە ئێستا هی شتێکی تر بێت، بۆیە هەڵە دەخوێنێتەوە، دەوەستێت یان نرخێکی تر دەسڕێتەوە. - : هەمان دوو جار ئازاد دەکرێتەوە. لیستی شوێنە ئازادەکانی تێک دەچێت و دواتر لەوانەیە یەک شوێن بدرێتە دوو خاوەن.
Garbage collection: memory freed for youفڕێدانی بەجێماوەکان: بیرگە بۆت ئازاد دەکرێتەوە
Most languages today free heap memory for you. A part of the language's run-time system, the garbage collector, finds the objects that have become garbage and frees them. John McCarthy invented garbage collection around 1959 for the language Lisp. Collectors use two main ideas, often together:
زۆربەی زمانەکانی ئەمڕۆ بۆت ئازاد دەکەنەوە. بەشێک لە سیستەمی کارکردنی زمانەکە، واتە سیستەمی ، ئەو دەدۆزێتەوە کە بوونەتە بەجێماو و ئازادیان دەکاتەوە. John McCarthy نزیکەی ساڵی 1959 بۆ زمانی Lisp داهێنا. ئەم سیستەمانە دوو بیرۆکەی سەرەکی بەکار دەهێنن، زۆرجار پێکەوە:
- Reference counting: every object counts the references to it and is freed when the count reaches 0.
- Tracing: from time to time, follow the references from the roots, keep everything you reach and free the rest. The basic tracing method is mark and sweep.
- : هەر خۆی دەژمێرێت و کاتێک ژمارەکە دەگاتە 0 ئازاد دەکرێتەوە.
- شوێنکەوتن: جار جار لە شوێن بکەوە، هەموو ئەوەی پێی دەگەیت بیهێڵەرەوە و ئەوانی تر ئازاد بکەرەوە. ڕێگای بنەڕەتیی شوێنکەوتن ـە.
You still decide what to keep: a collector frees only the objects that nobody can reach.
هێشتا تۆ بڕیار دەدەیت چی بمێنێتەوە: سیستەمی تەنیا ئەو ئازاد دەکاتەوە کە کەس پێیان ناگات.
Reference countingژماردنی ئاماژەکان
With reference counting, every object on the heap carries a number: how many references point to it. A new reference adds 1; when a reference is changed or disappears, 1 is taken away. When the count reaches 0, nobody can reach the object, so it is freed at once.
لە هەر لە ژمارەیەک هەڵدەگرێت: چەند بۆی هەیە. نوێ 1 زیاد دەکات؛ کاتێک دەگۆڕێت یان نامێنێت، 1 کەم دەکرێتەوە. کاتێک ژمارەکە دەگاتە 0، کەس ناتوانێت بە بگات، بۆیە دەستبەجێ ئازاد دەکرێتەوە.
a ← NEW LIST // the list's count: 1
b ← a // 2
a ← NULL // 1
b ← NULL // 0: freed nowThe good side: memory comes back at once and evenly, without long pauses. The cost: every assignment must update counts. The standard Python (CPython), PHP and Swift all use reference counting.
لایەنی باش: دەستبەجێ و بە ڕێکی دەگەڕێتەوە، بێ وەستانی درێژ. تێچووەکەی: هەموو دانانێک دەبێت ژمارەکان نوێ بکاتەوە. Pythonـی ستاندارد (CPython)، PHP و Swift هەموویان بەکار دەهێنن.
Reference countingژماردنی ئاماژەکان
The weak spot: reference cyclesلاوازییەکەی: بازنەکانی ئاماژە
Two objects can refer to each other: a person object keeps its flat, and the flat object keeps its tenant. When the program drops both variables, each object still has one reference, from the other one. The counts stay at 1 forever, so pure reference counting never frees them: a reference cycle leaks.
دوو دەتوانن ئاماژە بە یەکتر بکەن: کەسێک خانووەکەی ڕادەگرێت و خانووەکەش کرێچییەکەی. کاتێک هەردوو وازلێدێنێت، هەر هێشتا یەک هەیە، لە ئەویترەوە. ژمارەکان بۆ هەمیشە لە 1ـدا دەمێننەوە، بۆیە بە تەنیا هەرگیز ئازادیان ناکاتەوە: دەبێتە .
x ← NEW PERSON
y ← NEW FLAT
x.home ← y // the flat's count: 2
y.tenant ← x // the person's count: 2
x ← NULL // person: 1
y ← NULL // flat: 1, nobody can reach them, but no count is 0Languages fix this in two ways. Python and PHP add a cycle collector that looks for groups of objects reachable only from each other and frees them. Swift asks the programmer to mark one side as a weak reference (weak), which does not count, so the cycle never forms.
زمانەکان ئەمە بە دوو ڕێگا چارەسەر دەکەن. Python و PHP سیستەمێکی کۆکردنەوەی بازنەکان زیاد دەکەن کە بە دوای ئەو کۆمەڵە دەگەڕێت کە تەنیا لە یەکترەوە دەگەیەنرێن و ئازادیان دەکاتەوە. Swift داوا لە بەرنامەساز دەکات کە لایەکیان وەک (weak) نیشانە بکات، کە ناژمێردرێت، بۆیە بازنەکە هەرگیز دروست نابێت.
Tracing: mark and sweepشوێنکەوتن: نیشانەکردن و ماڵین
A tracing collector does not count. From time to time it works in two phases. Mark: start at the roots, follow every reference and mark each object you reach. Sweep: walk through the whole heap and free every object without a mark, then clear the marks for next time. A ring of objects that no root reaches is never marked, so cycles are no problem.
سیستەمێکی شوێنکەوتن ناژمێرێت. جار جار بە دوو قۆناغ کار دەکات. نیشانەکردن: لە دەست پێ بکە، شوێن هەموو بکەوە و هەر کە پێی دەگەیت نیشانە بکە. ماڵین: بە هەموو بڕۆ و هەر کە نیشانەی نییە ئازاد بکەرەوە، پاشان نیشانەکان بۆ جاری داهاتوو بسڕەوە. بازنەیەک لە کە هیچ پێی ناگات هەرگیز نیشانە ناکرێت، بۆیە بازنەکان کێشە نین.


The cost: a simple collector stops the program while it works, a pause. Modern collectors in Java, JavaScript and Dart do much of the work in small steps or on other processor cores while the program runs, so pauses are short.
تێچووەکەی: سیستەمێکی سادە لە کاتی کارکردنیدا دەوەستێنێت، واتە وەستانێک. سیستەمە نوێیەکانی Java، JavaScript و Dart زۆربەی کارەکە بە هەنگاوی بچووک یان لەسەر ناوکەکانی تری دەکەن لە کاتێکدا کار دەکات، بۆیە وەستانەکان کورتن.
Generations: most objects die youngنەوەکان: زۆربەی ئۆبجێکتەکان بە گەنجی دەمرن
Collector designers noticed a pattern: most objects are needed only for a moment, such as a temporary piece of text or the list for one calculation, while a few live for the whole run. A generational collector therefore splits the heap into a young area, where new objects are made, and an old area. It cleans the young area often, which is quick because most of it is already garbage. Objects that survive a few cleanings move up to the old area, which is cleaned only now and then.
دیزاینەرانی ئەم سیستەمانە شتێکیان تێبینی کرد: زۆربەی تەنیا بۆ ساتێک پێویستن، وەک پارچە دەقێکی کاتی یان لیستی یەک حیسابکردن، بەڵام کەمێکیان بە درێژاییی کارکردنەکە دەمێننەوە. بۆیە دابەش دەکات بۆ ناوچەیەکی گەنج، کە نوێی تێدا دروست دەکرێت و ناوچەیەکی پیر. ناوچە گەنجەکە زوو زوو پاک دەکاتەوە، کە خێرایە چونکە زۆربەی ئەوەی تێیدایە پێشتر بووە بە بەجێماو. ئەو لە چەند پاککردنەوەیەک ڕزگاریان دەبێت دەچنە ناوچە پیرەکە، کە تەنیا جار جار پاک دەکرێتەوە.
Java's collectors, JavaScript engines such as V8 (in Chrome and Node.js) and Dart all work by generations. CPython's cycle collector sorts objects into three generations too.
سیستەمەکانی Java، بزوێنەرەکانی JavaScript وەک V8 (لە Chrome و Node.jsـدا) و Dart هەموویان بەپێی نەوە کار دەکەن. سیستەمی کۆکردنەوەی بازنەکانی CPythonـیش دابەش دەکات بۆ سێ نەوە.
How popular languages do it (2026)زمانە باوەکان چۆن دەیکەن (2026)
Every language makes its own choice. The table shows the main approach of each one as of November 2026, checked in its official documentation.
هەر زمانێک هەڵبژاردنی خۆی هەیە. خشتەکە ڕێگای سەرەکیی هەر یەکێکیان پیشان دەدات، وەک لە تشرینی دووەمی 2026دا لە بەڵگەنامە فەرمییەکانیاندا پشکنراوە.
| Languageزمان | How heap memory is freed چۆن ئازاد دەکرێتەوە | Good to knowباشە بیزانیت |
|---|---|---|
| Python (CPython) | Reference counting and a cycle collector و سیستەمی کۆکردنەوەی بازنەکان | Most objects are freed as soon as their count reaches 0; the cycle collector sorts container objects into three generations.زۆربەی هەر کە ژمارەکەیان گەیشتە 0 ئازاد دەکرێنەوە؛ سیستەمی کۆکردنەوەی بازنەکان هەڵگر دابەش دەکات بۆ سێ نەوە. |
| Java (HotSpot JVM) | Tracing, generational collectorsشوێنکەوتن، | G1 is the default. In JDK 25 and 26 a machine with one processor or less than 1792 MB of memory gets the simple Serial collector instead; from JDK 27 (September 2026) G1 is the default everywhere. ZGC keeps pauses very short.G1 بنەڕەتییە. لە JDK 25 و 26ـدا ئامێرێک کە یەک پرۆسێسەر یان کەمتر لە 1792 MB هەبێت لە جیاتی ئەوە سیستەمی سادەی Serial وەردەگرێت؛ لە JDK 27ـەوە (ئەیلوولی 2026) G1 لە هەموو شوێنێک بنەڕەتییە. ZGC وەستانەکان زۆر کورت دەکاتەوە. |
| JavaScript | Tracing (mark and sweep), generationalشوێنکەوتن ()، بەپێی نەوە | No modern engine uses reference counting. V8 (Chrome, Node.js) copies surviving young objects and marks the old area in the background.هیچ بزوێنەرێکی نوێ بەکار ناهێنێت. V8 (Chrome، Node.js) گەنجە ڕزگاربووەکان کۆپی دەکات و ناوچە پیرەکە لە پشتەوە نیشانە دەکات. |
| Dart (Flutter) | Tracing, generationalشوێنکەوتن، بەپێی نەوە | Two generations: a fast copying collector for the young one, concurrent mark-sweep or mark-compact for the old one (why Flutter uses Dart).دوو نەوە: سیستەمێکی خێرای کۆپیکردن بۆ نەوە گەنجەکە و یان نیشانەکردن و پەستاندن بە هاوکاتی بۆ نەوە پیرەکە (بۆچی Flutter، Dart بەکار دەهێنێت). |
| PHP | Reference counting and a cycle collector و سیستەمی کۆکردنەوەی بازنەکان | Since PHP 5.3. The cycle collector is on by default and runs when 10,000 possible cycle roots have been recorded.لە PHP 5.3ـەوە. سیستەمی کۆکردنەوەی بازنەکان بە شێوەی بنەڕەتی چالاکە و کاتێک 10,000 ئەگەریی بازنە تۆمار دەکرێن کار دەکات. |
| Swift | Automatic reference counting (ARC) خۆکار (ARC) | No cycle collector: the programmer breaks cycles with weak or unowned references.سیستەمی کۆکردنەوەی بازنەکانی نییە: بەرنامەساز بازنەکان بە weak یان unowned دەشکێنێت. |
| C | By hand: malloc and freeبە دەست: malloc و free | Nothing is freed automatically; a mistake is a leak, a dangling pointer or a double free.هیچ شتێک بە شێوەی خۆکار ئازاد ناکرێتەوە؛ هەڵەیەک دەبێتە ، یان . |
| C++ | By hand, but mostly through RAIIبە دەست، بەڵام زۆرتر لە ڕێگەی RAIIـەوە | When an object goes out of scope, its clean-up code frees what it owns; std::unique_ptr and std::shared_ptr (which counts references) do this for heap memory.کاتێک لە دەردەچێت، کۆدی پاککردنەوەکەی ئەوەی هی خۆیەتی ئازادی دەکاتەوە؛ std::unique_ptr و std::shared_ptr (کە دەژمێرێت) ئەمە بۆ دەکەن. |
| Rust | Ownership checked by the compiler; no garbage collectorخاوەندارێتی کە دەیپشکنێت؛ بێ | Each value has one owner; when the owner goes out of scope, the value is dropped (freed). A double free is stopped before the program runs.هەر نرخێک یەک خاوەنی هەیە؛ کاتێک خاوەنەکە لە دەردەچێت، نرخەکە فڕێ دەدرێت (ئازاد دەکرێتەوە). پێش کارکردنی ڕێگری لێ دەکرێت. |
Leaks that still happen with a garbage collectorدزەکردنی بیرگە لەگەڵ فڕێدانی بەجێماوەکانیشدا
A collector frees only what nobody can reach. If your program still holds a reference to an object it will never use again, that object is not garbage. It is a leak that the collector cannot see. Typical causes:
سیستەمی تەنیا ئەوە ئازاد دەکاتەوە کە کەس پێی ناگات. ئەگەر هێشتا بۆ هەڵبگرێت کە هەرگیز دووپاتە بەکاری ناهێنێتەوە، ئەو بەجێماو نییە. کە سیستەمەکە نایبینێت. هۆکارە باوەکان:
- A list or store that only grows, such as a global list of every message ever shown, or a store of saved results with no limit.
- Listeners that are never removed: a screen registers a listener with a long-lived object and is then closed, but the listener still refers to the screen. Flutter widgets free such things in
dispose(). - Old data in long-lived objects: a field of an object that lives for the whole run still points to data from long ago.
- لیستێک یان کۆگایەک کە تەنیا گەورە دەبێت، وەک لیستێکی گشتیی هەموو ئەو پەیامانەی تا ئێستا پیشان دراون، یان کۆگایەکی ئەنجامە هەڵگیراوەکان بێ سنوور.
- ئەو هەرگیز لاناچن: شاشەیەک لای تەمەندرێژ تۆمار دەکات و پاشان دادەخرێت، بەڵام هێشتا ئاماژە بە شاشەکە دەکات. Flutter ئەم شتانە لە
dispose()ـدا ئازاد دەکەنەوە. - کۆن لە تەمەندرێژدا: کە بە درێژاییی کارکردنەکە دەژی هێشتا ئاماژە بە زۆر کۆن دەکات.
Leaks that still happen with a garbage collectorدزەکردنی بیرگە لەگەڵ فڕێدانی بەجێماوەکانیشدا
Good habitsخووە باشەکان
- Keep variables in the smallest scope: a local variable lets its object go when the call ends.
- Remove listeners and close files and connections when you are done (close every file).
- Give stores of saved results and histories a limit, or use weak references where the language offers them.
- Set a long-lived reference to null when you no longer need what it leads to.
- Do not call the collector by hand to “fix” memory; find what still holds the references. Memory tools, such as the Memory view of Flutter DevTools, show which path keeps an object alive.
- Without a collector (C): free every allocation exactly once, then set the pointer to NULL.
- لە بچووکترین ڕابگرە: کاتێک بانگکردنەکە تەواو دەبێت بەر دەدات.
- کاتێک تەواو بوویت لاببە و و پەیوەندییەکان دابخە (هەموو فایلێک دابخە).
- سنوورێک بۆ کۆگای ئەنجامە هەڵگیراوەکان و مێژووەکان دابنێ، یان لەو شوێنانەی زمانەکە دەیدات بەکار بهێنە.
- تەمەندرێژ بکە بە کاتێک ئیتر پێویستت بەوە نییە کە ئاماژەی پێ دەکات.
- سیستەمی بە دەست بانگ مەکە بۆ «چاککردنی» ؛ بیدۆزەرەوە چی هێشتا ڕادەگرێت. ئامرازەکانی ، وەک بەشی Memoryـی Flutter DevTools، پیشان دەدەن کام ڕێگا بە زیندوویی دەهێڵێتەوە.
- بێ سیستەمی (C): هەر ڕێک یەک جار ئازاد بکەرەوە، پاشان بکە بە NULL.
Common mistakesهەڵە باوەکان
| Mistakeهەڵە | What is trueڕاستییەکە |
|---|---|
| “A garbage collector means my program cannot leak memory.”«سیستەمی واتە ناتوانێت هەبێت.» | It frees only unreachable objects; references you forget to drop still leak.تەنیا نەگەیەنراو ئازاد دەکاتەوە؛ ئەو لەبیرت دەچێت لایانبەیت هێشتا دەبنە . |
| “The stack and the heap are different chips.”« و دوو پارچەی جیاوازن.» | Both are areas of the same RAM; the program uses them in different ways.هەردووکیان ناوچەی هەمان ؛ بە دوو شێوەی جیاواز بەکاریان دەهێنێت. |
| “The memory heap is the heap data structure.”« و یەک شتن.» | Same English word, different ideas: the memory heap is an area of memory; the heap data structure is a tree that keeps the smallest item on top.هەمان وشەی ئینگلیزی، دوو بیرۆکەی جیاواز: ناوچەیەکی ؛ هیپ دارێکە کە بچووکترین دانە لە سەرەوە دەهێڵێتەوە. |
“FREE(p) also empties p.”«FREE(p) pـیش بەتاڵ دەکاتەوە.» | p still holds the old address; set it to NULL yourself.p هێشتا ناونیشانە کۆنەکە هەڵدەگرێت؛ خۆت بیکە بە NULL. |
| “An object made inside a function is lost when the function returns.”« کە لە ناو دروست دەکرێت لەگەڵ گەڕانەوەی لەدەست دەچێت.» | Only the frame is removed. The object on the heap lives on while something refers to it.تەنیا چوارچێوەکە لادەبرێت. لە تا شتێک ئاماژەی پێ بکات دەژی. |
| “Calling the collector by hand often makes a program faster.”«بانگکردنی سیستەمی بە دەست زۆرجار خێراتر دەکات.» | Usually it makes it slower: collectors choose good moments themselves.زۆرجار خاوتری دەکات: ئەم سیستەمانە خۆیان کاتی باش هەڵدەبژێرن. |
| “Reference counting frees everything.”« هەموو شتێک ئازاد دەکاتەوە.» | Reference cycles need a cycle collector or weak references. پێویستیان بە سیستەمی کۆکردنەوەی بازنەکان یان هەیە. |
Exercisesڕاهێنانەکان
Use the bakery program from The call stack. (a) How many frames are on the call stack while line 2 runs, and what does each hold? (b) Which variables still exist when line 17 runs?
نانەواخانەکە لە ستاکی بانگکردن بەکار بهێنە. (a) لە کاتێکدا دێڕی 2 کار دەکات چەند چوارچێوە لەسەر و هەر یەکەیان چی هەڵدەگرێت؟ (b) کاتێک دێڕی 17 کار دەکات کام هێشتا ماون؟
Show answerوەڵامەکە پیشان بدە
(a) Three frames. Top: discount with total = 3000 and, once line 2 has run, off = 300. Middle: bill with count = 12, price = 250, total = 3000, waiting at line 9. Bottom: the main part with loaves = 12, waiting at line 16 (toPay has no value yet). (b) Only the main frame is left: loaves = 12 and toPay = 2700. The frames of discount and bill were removed when they returned.
(a) سێ چوارچێوە. سەرەوە: discount بە total = 3000 و دوای جێبەجێبوونی دێڕی 2، off = 300. ناوەڕاست: bill بە count = 12، price = 250، total = 3000، کە لە دێڕی 9دا چاوەڕێ دەکات. خوارەوە: بەشی سەرەکی بە loaves = 12، کە لە دێڕی 16دا چاوەڕێ دەکات (toPay هێشتا نرخی نییە). (b) تەنیا چوارچێوەی بەشی سەرەکی ماوە: loaves = 12 و toPay = 2700. چوارچێوەکانی discount و bill کاتی گەڕانەوەیان لابران.
Write the count of each list after every line. When is a list freed?
ژمارەی هەر لیستێک دوای هەر دێڕێک بنووسە. کەی لیستێک ئازاد دەکرێتەوە؟
a ← NEW LIST // list 1
b ← NEW LIST // list 2
c ← a
a ← b
c ← NULLShow answerوەڵامەکە پیشان بدە
| After lineدوای دێڕی | List 1لیستی 1 | List 2لیستی 2 |
|---|---|---|
| 1 | 1 (a) | — |
| 2 | 1 (a) | 1 (b) |
| 3 | 2 (a, c) | 1 (b) |
| 4 | 1 (c) | 2 (a, b) |
| 5 | 0: freed0: ئازاد کرایەوە | 2 (a, b) |
List 1 is freed at line 5, at the moment c lets go of it. List 2 is still alive at the end, with two references.
لیستی 1 لە دێڕی 5دا ئازاد دەکرێتەوە، هەر ئەو ساتەی c بەری دەدات. لیستی 2 لە کۆتاییدا هێشتا زیندووە، بە دوو .
The roots are r1 and r2. r1 → A, A → B, r2 → C, D → E, E → D, F → A. Which objects are marked, and which are swept? What would reference counting do with D, E and F?
r1 و r2ن. r1 ئاماژە بە A دەکات، A بە B، r2 بە C، D بە E، E بە D و F بە A. کام نیشانە دەکرێن و کامیان دەماڵرێن؟ چی لە D، E و F دەکات؟
Hintئاماژە
Follow arrows only in their direction, starting at r1 and r2.
تەنیا بە ئاراستەی تیرەکان بڕۆ، لە r1 و r2ـەوە دەست پێ بکە.
Show answerوەڵامەکە پیشان بدە
Marked: A (from r1), B (through A), C (from r2). Swept: D and E, which point only to each other, and F. F points to A, but nothing points to F, and marking follows arrows only away from the roots. A reference-counting system would free F (its count is 0) but never D and E (each has a count of 1).
نیشانەکراو: A (لە r1ـەوە)، B (لە ڕێگەی Aـەوە)، C (لە r2ـەوە). ماڵراو: D و E، کە تەنیا ئاماژە بە یەکتر دەکەن و F. F ئاماژە بە A دەکات، بەڵام هیچ شتێک ئاماژە بە F ناکات و نیشانەکردن تەنیا بە ئاراستەی دوورکەوتنەوە لە شوێن تیرەکان دەکەوێت. سیستەمێکی F ئازاد دەکاتەوە (ژمارەکەی 0ـە)، بەڵام هەرگیز D و E نا (هەر یەکەیان ژمارەی 1ـی هەیە).
This program runs on a language without a garbage collector. What is wrong, how much memory is lost, and how do you fix it?
ئەم لەسەر زمانێک کار دەکات کە سیستەمی نییە. چی هەڵەیە، چەند لەدەست دەچێت و چۆن چاکی دەکەیتەوە؟
FUNCTION makeGreeting()
p ← ALLOCATE(50)
WRITE "Hello" AT p
RETURN p
END FUNCTION
START
REPEAT 100 TIMES
g ← makeGreeting()
OUTPUT TEXT AT g
END REPEAT
ENDShow answerوەڵامەکە پیشان بدە
A memory leak: every call to makeGreeting allocates 50 bytes that are never freed, so the loop loses 100 × 50 = 5000 bytes. Free the greeting once it has been shown, and do not use g after that:
: هەر بانگکردنێکی makeGreeting 50 تەرخان دەکات کە هەرگیز ئازاد ناکرێتەوە، بۆیە 100 × 50 = 5000 لەدەست دەدات. دوای پیشاندانی سڵاوەکە ئازادی بکەرەوە و دوای ئەوە g بەکار مەهێنە:
REPEAT 100 TIMES
g ← makeGreeting()
OUTPUT TEXT AT g
FREE(g)
g ← NULL
END REPEATShilan's weather app adds a listener to the location service every time the forecast screen opens and never removes it. After the screen has been opened 200 times, the app uses a lot of memory, although it has a garbage collector. Explain why, and fix it.
ئەپی کەشوهەوای Shilan هەر جارێک شاشەی پێشبینی دەکرێتەوە لای خزمەتگوزاریی شوێن زیاد دەکات و هەرگیز لای نابات. دوای ئەوەی شاشەکە 200 جار کرایەوە، ئەپەکە زۆر بەکار دەهێنێت، هەرچەندە سیستەمی هەیە. ڕوونی بکەرەوە بۆچی و چاکی بکەرەوە.
Show answerوەڵامەکە پیشان بدە
The location service lives for the whole run. Every opening adds one more listener, and each listener still refers to its old, closed screen, so all 200 screens stay reachable from a root: the collector may not free them. Fix: remove the listener when the screen closes (in Flutter, in dispose()), or add it only once.
خزمەتگوزاریی شوێن بە درێژاییی کارکردنەکە دەژی. هەر کردنەوەیەک تر زیاد دەکات و هەر هێشتا ئاماژە بە شاشە کۆن و داخراوەکەی دەکات، بۆیە هەموو 200 شاشەکە لە دەگەیەنرێن: سیستەمەکە بۆی نییە ئازادیان بکاتەوە. چارەسەر: کاتێک شاشەکە دادەخرێت لاببە (لە Flutterـدا لە dispose()ـدا)، یان تەنیا یەک جار زیادی بکە.
Summaryپوختە
- A running program keeps its data in RAM, mainly in two areas: the call stack and the heap.
- Every call puts a frame with parameters, local variables and the return place on the stack; the return takes it off. Fast, automatic, small.
- The heap keeps objects that must outlive a call; variables hold references (or, in C and C++, pointers) to them.
- An object that no root can reach is garbage.
- By hand (C): every ALLOCATE needs exactly one FREE; mistakes are leaks, dangling pointers and double frees.
- Reference counting frees at count 0 but needs help with cycles; mark and sweep keeps what the roots reach; generational collectors clean the young area often.
- A collector cannot free what you still refer to: drop references, remove listeners, limit stores.
- کارا لە هەڵدەگرێت، بە تایبەتی لە دوو ناوچەدا: و .
- هەر بانگکردنێک چوارچێوەیەک بە ، و شوێنی گەڕانەوەوە دەخاتە سەر ؛ گەڕانەوە لای دەبات. خێرا، خۆکار، بچووک.
- ئەو هەڵدەگرێت کە دەبێت لە بانگکردنێک زیاتر بمێنن؛ (یان لە C و C++ـدا ) بۆیان هەڵدەگرن.
- کە هیچ پێی ناگات بەجێماوە.
- بە دەست (C): هەر ALLOCATE پێویستی بە ڕێک یەک FREE هەیە؛ هەڵەکان ، و ن.
- لە ژمارە 0ـدا ئازاد دەکاتەوە بەڵام بۆ یارمەتیی پێویستە؛ ئەوە دەهێڵێتەوە کە پێی دەگەن؛ ناوچە گەنجەکە زوو زوو پاک دەکاتەوە.
- سیستەمی ناتوانێت ئەوە ئازاد بکاتەوە کە هێشتا ئاماژەی پێ دەکەیت: لاببە، لاببە، کۆگاکان سنووردار بکە.
Why can a frame be freed without a garbage collector?بۆچی چوارچێوەیەک بێ سیستەمی فڕێدانی بەجێماوەکان ئازاد دەکرێتەوە؟
Its life ends exactly when its call returns, so the program simply removes the top frame. Heap objects have no such fixed end.
تەمەنی ڕێک ئەو کاتە کۆتایی دێت کە بانگکردنەکەی دەگەڕێتەوە، بۆیە بە سادەیی چوارچێوەی سەرەوە لادەبات. کۆتاییەکی جێگیری وایان نییە.
What is the difference between a reference and a pointer?جیاوازیی نێوان ئاماژە و ئاماژەدەر چییە؟
Both lead to an object. A pointer is the memory address itself, which C and C++ let you calculate with; a reference hides the address, and the language checks how you use it.
هەردووکیان دەتبەنە لای . خودی کە C و C++ ڕێگەت دەدەن حیسابی پێ بکەیت؛ ناونیشانەکە دەشارێتەوە و زمانەکە چاودێریی ئەوە دەکات چۆن بەکاری دەهێنیت.
Which handles cycles: reference counting or mark and sweep?کامیان بازنەکان چارەسەر دەکات: ژماردنی ئاماژەکان یان نیشانەکردن و ماڵین؟
Mark and sweep: a ring that no root reaches is never marked. Reference counting needs a cycle collector or weak references.
: بازنەیەک کە هیچ پێی ناگات هەرگیز نیشانە ناکرێت. پێویستی بە سیستەمی کۆکردنەوەی بازنەکان یان هەیە.
Next: plan programs step by step in Algorithms, Pseudocode and Flowcharts.
دواتر: هەنگاو بە هەنگاو پلان بکە لە ئەلگۆریزمەکان، نیمچەکۆد و هێڵکارییەکانی ڕەوت.
Lesson complete!وانەکە تەواو بوو!
Well done. Review the key terms, then go on to the next lesson.دەستخۆش. سەیرێکی زاراوە سەرەکییەکان بکەرەوە، پاشان بڕۆ بۆ وانەی داهاتوو.
Key termsزاراوە سەرەکییەکان
Algorithms, Pseudocode and Flowchartsئەلگۆریزمەکان، نیمچەکۆد و هێڵکارییەکانی ڕەوت
Related lecturesوانە پەیوەندیدارەکان
- Memory: RAM, ROM and Cacheبیرگە: RAM، ROM و کاش
- How a Computer Runs a Programکۆمپیوتەر چۆن بەرنامەیەک جێبەجێ دەکات
- Lists, References, Copies and Functionsلیستەکان، ئاماژەکان، کۆپی و کردارەکان
- Recursionخۆبانگکردنەوە
- Recursionخۆبانگکردنەوە
- Classes and Objects: Attributes and Methodsکلاسەکان و ئۆبجێکتەکان: تایبەتمەندییەکان و میتۆدەکان
- What Is Flutter?Flutter چییە؟
- Stacks: Last In, First Outستاکەکان: دوایین هاتوو، یەکەم دەرچوو
- Where Vulnerabilities Come Fromخاڵە لاوازەکان لە کوێوە دێن
- Priority Queues and Heapsکیووە پێشینەییەکان و هیپەکان
References and further readingسەرچاوەکان و خوێندنەوەی زیاتر
- Python documentation: gc — Garbage Collector interface (Python 3.15; the collector supplements reference counting, three generations)
- CPython InternalDocs: Garbage collector design (reference counting is the main algorithm; cycles; generations)
- Python documentation: Memory management (a private heap holds all Python objects)
- What's New in Python 3.14 (the incremental collector of 3.14.0–3.14.4 was reverted in 3.14.5)
- The Java Virtual Machine Specification, Java SE 25: §2.5.2 stacks, §2.5.3 heap, §2.6 frames
- Oracle: HotSpot Garbage Collection Tuning Guide, JDK 25 — Ergonomics (G1 on server-class machines, Serial otherwise)
- Inside Java: JEP 523, Make G1 the Default Garbage Collector in All Environments, targeted to JDK 27
- MDN: Memory management in JavaScript (reachability, reference counting and cycles, mark and sweep)
- V8 blog: Trash talk — the Orinoco garbage collector (generations, scavenger, mark-compact, concurrent marking)
- Dart SDK: Garbage collection in the Dart VM (two generations, scavenger, concurrent mark-sweep)
- Flutter documentation: Use the Memory view (Dart heap, root object, retaining paths, leaks, dispose)
- PHP manual: Garbage Collection — Collecting Cycles (since PHP 5.3, root buffer of 10,000)
- The Swift Programming Language: Automatic Reference Counting (strong reference cycles, weak and unowned)
- cppreference: free (C) — double free and use after free are undefined behaviour
- cppreference: RAII (C++), with std::unique_ptr and std::shared_ptr
- The Rust Programming Language: What Is Ownership? (stack and heap, ownership rules, drop, double free)
- CISA: New Guidance Released for Reducing Memory-Related Vulnerabilities (with NSA, 24 June 2025)
- Wikipedia: Garbage collection (computer science) (John McCarthy, about 1959; tracing and reference counting)
This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.