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

  • SEARCH
  • Home
  • 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 174363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:30:30+00:00 2026-05-11T13:30:30+00:00

As far as I know, strings are immutable in Delphi. I kind of understand

  • 0

As far as I know, strings are immutable in Delphi. I kind of understand that means if you do:

string1 := 'Hello'; string1 := string1 + ' World'; 

first string is destroyed and you get a reference to a new string ‘Hello World’.

But what happens if you have the same string in different places around your code?

I have a string hash assigned for identifying several variables, so for example a ‘change’ is identified by a hash value of the properties of that change. That way it’s easy for me to check to ‘changes’ for equality.

Now, each hash is computed separately (not all the properties are taken into account so that to separate instances can be equal even if they differ on some values).

The question is, how does Delphi handles those strings? If I compute to separate hashes to the same 10 byte length string, what do I get? Two memory blocks of 10 bytes or two references to the same memory block?

Clarification: A change is composed by some properties read from the database and is generated by an individual thread. The TChange class has a GetHash method that computes a hash based on some of the values (but not all) resulting on a string. Now, other threads receive the Change and have to compare it to previously processed changes so that they don’t process the same (logical) change. Hence the hash and, as they have separate instances, two different strings are computed. I’m trying to determine if it’d be a real improvement to change from string to something like a 128 bit hash or it’ll be just wasting my time.

Edit: Version of Delphi is Delphi 7.0

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T13:30:31+00:00Added an answer on May 11, 2026 at 1:30 pm

    Delphi strings are copy on write. If you modify a string (without using pointer tricks or similar techniques to fool the compiler), no other references to the same string will be affected.

    Delphi strings are not interned. If you create the same string from two separate sections of code, they will not share the same backing store – the same data will be stored twice.

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

Sidebar

Related Questions

As far as I know a string in C# is a reference type. So
As far as I know, in Java I can Object o = new String(abc)
So far I know that FileSystemWatcher can look into a folder and if any
As far as I know that JSF keeps all the session scoped bean in
as far as I know strings (REG_SZ) created in the windows registry must be
As far as I know arrays are allocated statically but strings are dynamic as
As far as know, I must be careful with PHP, and I think Javascript.
as far as I know both 2012-07-04T17:30:52+00:00 and 2012-07-04T17:30:52Z are dates in iso8601 format
As far as I know there is no way to migrate existing Facebook comments
As far as I know, C2DM is per app per device thing..but my question

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.