﻿1
00:00:00,000 --> 00:00:06,880
Now flip that over to the heap where we have basically uncategorized memory and this is where

2
00:00:06,880 --> 00:00:11,520
everything else goes and when I say everything else I'm talking about uncategorized on not

3
00:00:11,520 --> 00:00:18,320
playing by the rules type files because they're not necessarily programs per se they're just data

4
00:00:18,320 --> 00:00:23,680
files it would be a prime example. Let's say you go to a website and you decide that you want to

5
00:00:23,680 --> 00:00:31,040
watch a video. That video is going to be taking up space inside the RAM because it's not going

6
00:00:31,040 --> 00:00:37,279
to go on the hard drive itself. Just as you're streaming this video right now learning about

7
00:00:37,279 --> 00:00:43,599
running memory it's not taking up space on your hard drive. You can go through and do a hash

8
00:00:43,599 --> 00:00:48,560
bit for bit on your hard drive and it would never change even while this video is playing.

9
00:00:49,360 --> 00:00:54,480
But what you would notice is that this video is taking up space inside the memory which is also

10
00:00:54,480 --> 00:01:00,959
partly why some videos have a time limit on them especially here at CBT Nuggets. We try not to

11
00:01:00,959 --> 00:01:06,639
make them too long taking that into consideration because the longer the video the more RAM or

12
00:01:06,639 --> 00:01:15,120
running memory it takes up. And this happens in the way that you would think it would that when

13
00:01:15,120 --> 00:01:21,919
that memory reaches maximum and you've reached the limit of physical RAM on the system that

14
00:01:21,919 --> 00:01:26,879
basically it just starts dumping whatever it's not needed inside the running memory itself to make

15
00:01:26,879 --> 00:01:33,760
room for more of the actual data itself. This also ties into the counterpoint of what we were talking

16
00:01:33,760 --> 00:01:41,120
about just a few minutes ago where in the stack you would have a character or a variable of some

17
00:01:41,120 --> 00:01:47,199
type that had a certain limit pre-defined limit to it. Well in this particular case you can have a

18
00:01:47,199 --> 00:01:53,919
variable with an undefined limit to it and the basic premise is that the heap is going to provide

19
00:01:53,919 --> 00:02:02,800
the memory for that. So if you do have a character that is 50 characters long and a user puts in 55

20
00:02:02,800 --> 00:02:08,000
depending on its configuration inside the actual programming then it would actually pull from the

21
00:02:08,000 --> 00:02:15,600
heap instead of going to the stack and having a fully defined fixed array or a fixed buffer inside

22
00:02:15,600 --> 00:02:22,639
the running memory. Now as an example and I'm not coding this anywhere because it'd be very difficult

23
00:02:22,639 --> 00:02:27,679
to actually show you how this actually operated behind the scenes. I'm going to put a little bit

24
00:02:27,679 --> 00:02:34,559
of code snippet below this video to show you the differences between a snippet of program code

25
00:02:34,559 --> 00:02:40,639
that's for running in the stack and some of it that's running in the heap of the actual memory

26
00:02:40,639 --> 00:02:47,279
itself. You can see that stuff that's being called upon in the stack or a piece of code that will go

27
00:02:47,279 --> 00:02:53,119
to the stack is way more structured than something that would actually go into the heap. So just a

28
00:02:53,119 --> 00:02:59,919
quick comparison and hopefully that code will iron out any questions that you have if there are some

29
00:02:59,919 --> 00:03:01,759
still remaining over this.


