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

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

问题描述

就像标题一样,什么是连续内存块?

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 个下划线字符,| 符号不代表内存):

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):

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

它看起来不像这样:

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

它看起来也不是这样:

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

在所有情况下,看起来像"的意思是就 C 中可见的地址而言".某些东西在虚拟地址空间中可能是连续的,但在物理 RAM 中却不是连续的.就此而言,某些东西在物理 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天全站免登陆