0

My current question is related to Max length for a dynamic array in Delphi?. That question was asked in 2009 when the 64 bit compiler was not available. I am preparing migration to Delphi XE2 (or whatever version is available for purchase not) or to Lazarus because I need 64 bit support.

I would like to know what changed (related to dynamic array max length) in Delphi 64bit. Can I create bigger arrays now?

1 Answer 1

6

Dynamic array lengths are, in modern Delphi, NativeInt.

This means that dynamic arrays are limited in theory to 32 bit lengths in 32 bit code, and 64 bit length in 64 bit code. Of course, practical considerations mean that the limits are somewhat lower. However it is possible to allocate dynamic arrays with more than 232 elements in 64 bit code.

On the other hand, strings are subject to a 32 bit limit on their length for all architectures. As I understand it the reasoning is that strings are simply not expected to hold such large amounts of text. And many of the text support library functions that strings rely on use 32 bit lengths. Whereas arrays are used for more general purpose computing and a 32 bit limit would greatly reduce their utility under 64 bits.

Sign up to request clarification or add additional context in comments.

13 Comments

Thanks Davis. Very prompt answer as usual.
"As I understand it the reasoning is that strings are simply not expected to hold such large amounts of text." It's a violation of the "0,1,infinity" rule though: en.wikipedia.org/wiki/Zero_one_infinity_rule I've seen biology programs processing genetic sequences that find it very useful to use a string greater than 2GB.
@alcalde-Indeed. I have a 32GB RAM PC and still need a RAM upgrade to process all data.
Genetic sequences are hold in ASCII strings (well you can hold them also in Unicode if you want to waste some RAM). They are characters A,C,G,T for DNA nucleotides and other alphabetic characters for ambiguous bases and proteins. Also - for Gap.
1. I never said that. The DNA is a molecule not a computer string:) What I said is that you need more the 4 chars (ACGT) to represent a DNA sequence or protein. Please take a look at the UIPAC code and you will see. 2. Encoding DNA on a number of bits lower than 8 will make the things terribly slow. In many cases you need to compare or to assemble two looooong sequences. In this case it is better to keep the data unpacked (as byte or ANSI string).
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.