1. Tubelator AI
  2. >
  3. Videos
  4. >
  5. People & Blogs
  6. >
  7. Garbage collection and ABA problem in concurrency with example

Garbage collection and ABA problem in concurrency with example

Available In Following Subtitles
English
Variant 1
Posted on:
#Garbage#collection#and#ABA#problem#in#concurrency#with#example#Karanjetlilive#it#lectures
tubelator logo

Instantly generate YouTube summary, transcript and subtitles!

chrome-icon Install Tubelator On Chrome

Video Summary & Chapters

No chapters for this video generated yet.

Video Transcript

0:03
Hi guys, welcome to my channel and today in this video we are going to discuss garbage
0:08
collection and ABA problem in concurrency.
0:12
So guys for the full lecture all of you stay tuned.
0:15
So guys first thing first what is garbage collection?
0:18
So all of you those who study data structures, okay, they must have come across this term.
0:23
We call it as garbage collection what it is.
0:25
Guys, garbage collection is the process of collecting all the free notes or collecting
0:31
all the deleted data and putting them in an available pool.
0:37
What is available pool?
0:38
Available pool is another step.
0:40
structure in which we append all the deleted nodes so that they can be reused.
0:48
For example, this is our linked list.
0:52
So it has three elements A, A is pointing to B, B is pointing to C. So suppose the address
1:03
of A is 100, address of node B is 110, address of node C is 120.
1:12
And then we have a start which is pointing to the first node that is 100 and C is not
1:23
pointing anywhere so that is none.
1:25
Suppose this is my linked list.
1:28
Now in this linked list suppose I delete node A. Suppose I delete node A. How do we delete
1:34
node A, we delete the node A by changing the address of start.
1:39
So earlier it was pointing to 100, now it will point to 110.
1:44
Now it will point to 110.
1:47
So what will happen?
1:49
Automatically this start, instead of pointing to A, it will start pointing to B. And my
1:57
linked list will start from the B. So you go to start.
2:01
What is the first node?
2:02
110 then 120 and so on. A gets deleted from here. A gets deleted from here. Now this is
2:11
a deleted node. Okay. This is a deleted node. What is a garbage collection? Garbage collection
2:17
is the process in which all such deleted nodes are collected together. Okay. And they are
2:24
put in an available list for recycling. Now what is the available list? It is the list
2:30
of all the deleted nodes so that whenever we need a new node we can take we can pick
2:36
a node from the available list.
2:38
So here spool we have a available list A B A I L list.
2:44
So avail list now A got deleted avail list will point to A. So what we have here is the
2:59
deleted node A.
3:00
Now, suppose in this list, in this list, in this list, node B also gets deleted.
3:07
How do we delete it?
3:08
We change the starting address from 110 to 120.
3:14
So what will happen?
3:16
The start will point from 110 to 120.
3:22
Then what do we do?
3:23
Again, we bring this list, again we bring this node B to available list.
3:30
So what A will point to?
3:32
Now we will modify our available list, A will point to 110.
3:37
So what comes here is after A comes and B is pointing to null and available header was
3:47
pointing to 110.
3:50
So what happened?
3:50
from this list I deleted two nodes that was node A and that was node B. So all two nodes they became
3:59
where the we I moved them to available list. So from here we can recycle that.
4:07
So from here we
4:08
can recycle them. For example, after some time again we need to insert a node in our this list.
shape-icon

Download extension to view full transcript.

chrome-icon Install Tubelator On Chrome