Forum > Beginners

Memory layout and management questions

<< < (3/3)

K.IO.s:
Just to be clear about this, taking the 2d array example.
The top array is a pointer, which points to a series of bottom arrays, that are also pointers to a memory location.
This memory location that contains the actual data, is contiguous correct?
I mean per section of course. So array[0][0...N] would be a contiguous segment, just as array[1][0...N] would, etc.

SymbolicFrank:
Yes. SetLength copies the array if needed.

Thaddy:
It only copies when lengthed, not when shorted.

MarkMLl:

--- Quote from: K.IO.s on July 06, 2022, 04:00:00 pm ---Just to be clear about this, taking the 2d array example.
The top array is a pointer, which points to a series of bottom arrays, that are also pointers to a memory location.
This memory location that contains the actual data, is contiguous correct?
I mean per section of course. So array[0][0...N] would be a contiguous segment, just as array[1][0...N] would, etc.

--- End quote ---

I would suggest that "opaque reference" is more appropriate than "pointer", and to leave considerations of dereferencing, reallocation etc. to the compiler and runtimes.

However I believe your conclusion is broadly correct: the data in an array is contiguous, rather than being allocated as e.g. a tree of system-sized pages.

MarkMLl

K.IO.s:

--- Quote from: MarkMLl on July 06, 2022, 05:02:41 pm ---... rather than being allocated as e.g. a tree of system-sized pages.

--- End quote ---

Exactly! :D

Thank you guys for all the replies, this clear up a lot. For a moment I thought Pascal had strange defaults, but it seems to be as expected.

Navigation

[0] Message Index

[*] Previous page

Go to full version