Now flip that over to the heap where we have basically uncategorized memory and this is where
everything else goes and when I say everything else I'm talking about uncategorized on not
playing by the rules type files because they're not necessarily programs per se they're just data
files it would be a prime example. Let's say you go to a website and you decide that you want to
watch a video. That video is going to be taking up space inside the RAM because it's not going
to go on the hard drive itself. Just as you're streaming this video right now learning about
running memory it's not taking up space on your hard drive. You can go through and do a hash
bit for bit on your hard drive and it would never change even while this video is playing.
But what you would notice is that this video is taking up space inside the memory which is also
partly why some videos have a time limit on them especially here at CBT Nuggets. We try not to
make them too long taking that into consideration because the longer the video the more RAM or
running memory it takes up. And this happens in the way that you would think it would that when
that memory reaches maximum and you've reached the limit of physical RAM on the system that
basically it just starts dumping whatever it's not needed inside the running memory itself to make
room for more of the actual data itself. This also ties into the counterpoint of what we were talking
about just a few minutes ago where in the stack you would have a character or a variable of some
type that had a certain limit pre-defined limit to it. Well in this particular case you can have a
variable with an undefined limit to it and the basic premise is that the heap is going to provide
the memory for that. So if you do have a character that is 50 characters long and a user puts in 55
depending on its configuration inside the actual programming then it would actually pull from the
heap instead of going to the stack and having a fully defined fixed array or a fixed buffer inside
the running memory. Now as an example and I'm not coding this anywhere because it'd be very difficult
to actually show you how this actually operated behind the scenes. I'm going to put a little bit
of code snippet below this video to show you the differences between a snippet of program code
that's for running in the stack and some of it that's running in the heap of the actual memory
itself. You can see that stuff that's being called upon in the stack or a piece of code that will go
to the stack is way more structured than something that would actually go into the heap. So just a
quick comparison and hopefully that code will iron out any questions that you have if there are some
still remaining over this.