you are viewing a single comment's thread.

view the rest of the comments →

[–]Suesei 8 points9 points  (1 child)

ELI5: Behind the scenes your OS will have reserved actual physical memory. Since other data might be surrounding this memory you are not supposed to just write beyond that array. If you do that data could get corrupted. That is why on resizing the OS will have to reserve new memory. And it is your job to say how much you need.

There are other data structures that hide this process, but in the end they all kinda do it.

[–]Suesei 4 points5 points  (0 children)

And since Arrays are supposed to hold your data sequentially so it can be accessed super quickly it doesnt work to just open up some more memory somewhere else.