Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8051701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:21:34+00:00 2026-06-05T07:21:34+00:00

Strings in Delphi locating in dynamic memory. How to calculate actual memory (in bytes)

  • 0

Strings in Delphi locating in dynamic memory.

How to calculate actual memory (in bytes) used by string variable?

I know the string must store some additional information, at least reference count and length, but how many bytes it uses except characters?

var
  S: string;

Delphi 2010, XE, XE2 used

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:21:35+00:00Added an answer on June 5, 2026 at 7:21 am

    The layout on 32 bit UNICODE DELPHI taken from official Embarcadero documentation is like this:

    UNICODE DELPHI

    Note that there’s an additional longint field in the 64 bit version for 16 byte alignment. The StrRec record in ‘system.pas’ looks like this:

    StrRec = packed record
    {$IF defined(CPUX64)}
      _Padding: LongInt; // Make 16 byte align for payload..
    {$IFEND}
      codePage: Word;
      elemSize: Word;
      refCnt: Longint;
      length: Longint;
    end;
    

    The payload is always 2*(Length+1) in size. The overhead is 12 or 16 bytes, for 32 or 64 bit targets. Note that the actual memory block may be larger than needed as determined by the memory manager.

    Finally, there has been much mis-information in this question. On 64 bit targets, strings are still indexed by 32 bit signed integers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So the question is whether or not string literals (or const strings) in Delphi
Delphi strings use single quotes, for example ' a valid string '. How does
In our Delphi application, we use a TStringList to store strings and corresponding objects.
g'morning! i fill a dictionary TDictionary<String, TStringlist> (delphi-collections-unit) with strings as values and several
I know that when I share strings between a Delphi APP and a Delphi
As far as I know, strings are immutable in Delphi. I kind of understand
Delphi 2009 and above uses unicode strings for their default string type. To my
From my knowledge strings are 1 based in Delphi, 0 position is reserved for
In Delphi, there is a function StrToInt() that converts a string to an integer
I'm trying to find a Delphi function that will split an input string into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.