Hi everybody.
Welcome to the next memory video and this video we're gonna be talking about the heap in the last video
we talked about the stock.
So again we're going to look at the values or the structure here against.
We have the stack some data from the stack and then we've got the heap.
Now the heap is an important piece to understand because there are heap spring based exploits out there
just like there are Stack Overflow based exploits.
Now the heap doesn't take the standard structures like the stack does.
So the stack takes a certain variables it takes integers strings etc. The heap will handle objects or
larger amounts of data in data sets.
Now it's important to understand that while the stack keeps a neat order in its FIFO data structure
and like I said it's important to keep that stack in alignment because if you misplace it it can be
anywhere in memory.
However with the heap it's it's up to do that to the developer to keep everything nice and tidy.
So the heap can be a giant mess in memory.
It's not it's not ran by anything.
It's not it's not controlled as far as ordering everything.
There's nothing only the developer of the application running is handling the heap.
Now for you Java developers out there you'll find that a lot of issues you run into when you create
too many objects or you create and you don't use garbage collection enough you're going to run into
problems where you get out of memory or your heap runs out of memory which is just as bad.
Now what's important to understand is garbage collection.
For those of you not familiar with it is the task that a compact than a compiler will go through during
rent or not a copilot but during runtime an application built compiled into the application to develop
a road.
We'll go through the keep and delete anything that's that no longer has a reference to it.
So there's no pointer referring to this object anymore.
It gets deleted from memory from the heap.
Now that's what garbage collection does and which is why it's so important for not just job applications
but for any application that handles the heap on its own.
Now again so create the application needs to create something it will do live like for example if you're
running through and you're dynamically building objects in your application it's going to be generated
and put into the heap again like I said it's it's manually managed by the developer.
It's easy to fragment the memory and easy to fill up.
And again for your Java developers it is garbage.
It is exactly what garbage collection is doing but for anybody who's not using an app language that
comes with garbage collection you have to do this yourself if you put something into the heap.
You have to make sure it is removed after the fact.
Otherwise you're just going to start running out of memory and then the application is going to use
too much and then the kernel is going to come through with the 0 1 killer and just kill the process.
So take some time read up on the heap as well as the stack.
Understand the difference between the two and where they in where they're used and how they're used.