Originale-mail to me for new edition

 

Dynamic array types

 

A dynamic-array variable occupies four bytes of memory which contain a pointer to the dynamically allocated array. When the variable is empty (uninitialized) or holds a zero-length array, the pointer is nil and no dynamic memory is associated with the variable. For a nonempty array, the variable points to a dynamically allocated block of memory that contains the array in addition to a 32-bit length indicator and a 32-bit reference count. The table below shows the layout of a dynamic-array memory block.

 

Offset

Contents

-8

32-bit reference-count

-4

32-bit length indicator (number of elements)

0..Length * (size of element) -1

array elements

 

Topic groups

 

See also

Dynamic arrays

Memory management: Overview

Variables

 

 

译文

 

动态数组类型

 

一个动态数组变量占用4个字节来保存指向动态分配数组的指针。当变量为空(未初始化的)或者保存了一个零长度的数组时,指针为nil并且没有任何动态内存与之相关联。对于一个非空的动态数组,变量指向一个动态分配的内存块,该内存块包含了数组、一个32位的长度指示器、一个32位的引用计数器。下表时动态数组内存块的布局:

 

偏移量

内容

-8

32位的引用计数器

-4

32位的长度指示器(元素个数)

0..Length * (size of element) -1

数组元素

 

主题组

 

相关主题

动态数组

内存管理:概述

变量