什么是一个连续的内存块? [英] What is a contiguous memory block?

查看:202
本文介绍了什么是一个连续的内存块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就像在标题,什么是一个连续的内存块?

Just like in the title, what is a contiguous memory block?

推荐答案

一个没有在它占据的地址没有任何间隙。你可能只认为这是一个块,而在中间的两大块。

One without any gaps in the addresses it occupies. You can probably just think of this as a "block", and think of something with a gap in the middle as "two blocks".

的术语以阵列的定义上来为连续的。这意味着元件被布置端至端,没有不连续性和它们之间没有填充(有可能​​是各元件内部填充,但不是元件之间)。因此5 4个字节元素的数组看起来像这样(每字节1下划线时,|符号不重新present内存):

The term comes up in the definition of an array as being "contiguous". That means the elements are laid out end-to-end, with no discontinuities and no padding between them (there may be padding inside each element, but not between elements). So an array of 5 4-byte elements looks like this (1 underscore character per byte, the | symbols don't represent memory):

 ____ ____ ____ ____ ____
|____|____|____|____|____|

它看起来并不像这样:

It doesn't look like this:

 ____ _ ____ _ ____ _ ____ _ ____
|____|_|____|_|____|_|____|_|____|

和它也不是这样的:

 ____ ____ ____                                           ____ ____
|____|____|____| ... somewhere completely different ...  |____|____|

在所有情况下,看上去像是指尽可能用C可见而言地址。东西可以在虚拟地址空间连续的,但在物理RAM不是连续的。对于这个问题,一些可能是在物理内存地址空间连续的,但在物理RAM实际上不相邻。其中有一半可能是在一个RAM芯片在这里,另一半上的另一个RAM芯片那边。但C内存模型不能看到任何。

In all cases, "looks like" means "as far as the addresses visible in C are concerned". Something could be contiguous in virtual address space, but not contiguous in physical RAM. For that matter, something could be contiguous in physical RAM address space, but not actually adjacent in physical RAM. Half of it could be on one RAM chip over here, and the other half on another RAM chip over there. But the C memory model can't "see" any of that.

这篇关于什么是一个连续的内存块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆