Skip to player
Skip to main content
Search
Connect
Watch fullscreen
Like
Bookmark
Share
More
Add to Playlist
Report
(Sigma batch 2025) what happened in memory by shradha didi
Prateek Prajapati
Follow
4 months ago
Sigma batch 2025
Category
📚
Learning
Transcript
Display full video transcript
00:00
Next, we will talk about what things are inside the memory.
00:04
We write a function and call it a function.
00:08
In memory, we will get a lot of special things.
00:12
We have done public, static, void.
00:16
If I have made a function, let's calculate sum.
00:20
I will have a variable like int a, a other variable like int b.
00:24
These are my formal parameters.
00:26
In this sum, I have made a new variable.
00:30
Int sum is equal to a plus b.
00:32
Then, I will print it as well.
00:34
Besides, I have made a public, static, void.
00:36
Main name function.
00:38
In my class.
00:40
In which I know I am taking a string of arguments.
00:44
I have called sum.
00:46
What is inside my memory?
00:50
Today, we have been able to imagine the time of the memory.
00:54
My memory is something like that.
00:56
Each variable is a little place.
00:58
It is a name of the variable.
01:00
It is a value store.
01:02
We knew that there is a value store.
01:04
We knew that there is a value store.
01:06
The variables occupy their memory.
01:08
But the functions also occupy the memory in Java.
01:12
For writing functions, there is a little memory.
01:16
They have some memory.
01:18
Where do they have memory?
01:20
They have called stack.
01:22
Stack which students have heard the first time term.
01:24
Stack means to keep things on top of one.
01:28
Like plates in restaurants.
01:30
We keep them on top of one.
01:32
We keep books on top of the table.
01:34
They keep on top of one.
01:36
We call stack of books.
01:38
Or stack of plates.
01:40
Stack is to keep things on top of one.
01:44
So, in Java, there is some parts that are organized in the stack.
01:48
So, it shows something like this.
01:50
First, there is some parts.
01:52
Then, there is some parts.
01:54
Then, there is some parts.
01:55
Then, there is some parts.
01:56
So, this way, they keep things on top of one.
01:58
So, this part of memory,
02:00
we call it call stack.
02:02
We call it call stack.
02:04
Call stack tracks.
02:05
Call stack tracks.
02:06
Which function has called.
02:07
Which function has called.
02:08
Which function has called.
02:09
Or, which function is called in our memory.
02:10
Now, we call it in our memory.
02:11
Or, we occupy some memory.
02:12
So, like a Java program is running.
02:14
Like this program is running.
02:15
So, what will happen first?
02:16
First of all, the main function will occupy some memory.
02:21
And, the amount of memory will occupy this stack.
02:24
This is my call stack.
02:26
I will call it a stack frame.
02:30
Frame is a hole.
02:33
So, the memory has occupied the main function.
02:37
Now, what is stored in this memory?
02:39
What is stored in this memory?
02:40
In this memory, all the variables are stored.
02:42
So, if I have made a sum.
02:46
Then, what will happen?
02:48
The main function stack frame will store the string type.
02:52
And, as the main function has called the sum.
02:55
So, the sum has called the call.
02:57
So, the stack frame has occupied the sum function.
03:01
So, the sum function will occupy this stack frame.
03:04
And, what will be stored in this sum function?
03:07
Because, the sum function of the integer variable is called sum.
03:11
So, the integer variable will occupy this stack frame.
03:17
If this sum calls some other function.
03:20
So, what will happen?
03:21
It will become another stack frame.
03:23
In which it will be named a new function.
03:25
And, its variables are stored here.
03:27
So, a function occupies on the stack frame.
03:32
And, what is stored in it?
03:34
It is stored in the function related information.
03:37
So, the input will be stored in it.
03:39
It will be stored in it.
03:40
The variables will be stored in it.
03:41
The variables will be stored in it.
03:43
So, this is why the function also needs memory.
03:45
It also needs memory.
03:46
And, it takes memory in the form of the call stack.
03:48
Now, the whole concept of the call stack.
03:50
We will be reading it again.
03:52
It will be basic in the name of the recursion.
03:55
So, if it is a little difficult to understand.
03:58
Then, we will study Oops.
04:00
We will discuss the functions in detail.
04:02
We will discuss the class in detail.
04:04
Then, we will study recursion.
04:05
So, when we are reading recursion,
04:07
We will discuss the call stack in detail.
04:09
And, all of the things will be clear.
04:11
So, why is it important to understand the memory?
04:15
Because, in the name of the recursion,
04:17
There is a wonderful technique in programming languages.
04:20
There are many algorithms that use it.
04:23
So, that is why,
04:24
It is important to understand the call stack.
04:26
Because, the call stack forms the basis of recursion.
04:29
So, the function is called.
04:30
So, the memory is reserved for that function.
04:33
And, as we have a return statement of function.
04:36
If we have a return statement here.
04:37
So, as I will execute the return statement.
04:38
And, in the name of the function,
04:39
If I have a return statement here.
04:40
So, after I execute this statement,
04:43
I will reach this return statement.
04:45
And, I will go into the main function.
04:49
So, what the function of the call stack has occupied memory,
04:51
will be removed.
04:52
And, as the main function will be removed.
04:56
So, the main function will be removed.
04:59
So, when the function is called,
05:01
It will occupy memory or place.
05:03
And, when it is done,
05:05
If the return statement is executed then it will be removed from the call stack.
Be the first to comment
Add your comment
Recommended
2:30
|
Up next
(Sigma batch)Introduction to a Function by shradha didi
Prateek Prajapati
4 months ago
3:42
(Sigma batch 2025) product os a&b by shradha didi
Prateek Prajapati
4 months ago
8:15
(Sigma batch 2025) call by values by shradha didi
Prateek Prajapati
4 months ago
10:23
(Sigma batch 2025) syntax function code by shradha didi
Prateek Prajapati
4 months ago
6:23
(Sigma batch 2025) syntax with parameters by shradha didi
Prateek Prajapati
4 months ago
1:55
(Sigma batch 2025) parameters v/s arguments by shradha didi
Prateek Prajapati
4 months ago
1:22
Sigma & Take That On GMB #Cry
Michelle Thornton
10 years ago
1:57
Sigma Girl Expression
Wrestling Arena Anime
3 years ago
2:02
Sigma FP Concept Movie
xataka
5 years ago
0:11
Sigma rule
Jack Sparrow
2 years ago
0:51
Former Aide Claims She Was Asked to Make a ‘Hit List’ For Trump
Veuer
2 years ago
1:08
Musk’s X Is ‘the Platform With the Largest Ratio of Misinformation or Disinformation’ Amongst All Social Media Platforms
Veuer
2 years ago
4:50
59 companies that are changing the world: From Tesla to Chobani
Fortune
2 years ago
0:46
3 Things to Know About Coco Gauff's Parents
People
2 years ago
1:18
USC vs. Colorado: Can Caleb Williams Earn a New Heisman Moment?
SportsGrid
2 years ago
1:04
Vic Mensa Reveals Celebrity Crush, Biggest Dating Pet Peeve & More on Speed Dating | Billboard News
Billboard
2 years ago
1:09
Hollywood Writers Reach ‘Tentative Agreement’ With Studios After 146 Day Strike
Veuer
2 years ago
1:26
Love is Blind stars admit they're burnt out from social media
Fortune
2 years ago
2:01
NHA Customers in Limbo as Company Faces Potential Merger
SportsGrid
2 years ago
2:55
Vanilla Ice Explains How the 90’s Shaped America
FACTZ
2 years ago
0:36
Amazon’ Prime Video Will Show Commercials Starting Next Year
Veuer
2 years ago
11:13
Pokimane Answers The Web's Most Searched Questions
WIRED
2 years ago
4:16
BREAKING NEWS: Matt Gaetz Tells House Committee: 'I'm Not Going To Vote For A Continuing Resolution'
Forbes Breaking News
2 years ago
1:00
What's Popular on Uber Eats?
Stringr
2 years ago
2:50
MÃ¥neskin Performs "HONEY" at MSG
Rolling Stone
2 years ago
Be the first to comment