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 8906543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:41:03+00:00 2026-06-15T02:41:03+00:00

According to tryruby.org , the usage of a symbol uses one memory allocation, and

  • 0

According to tryruby.org, the usage of a symbol uses one memory allocation, and then points to its single allocation, whereas storing multiple strings, even if they are the same, stores multiple instances in the memory. So, much like how MP3 and other compression or optimization methods work, what considerations go into switching from multiple strings to refactoring to usage of symbols to take advantage of the repetition? As soon as you have two duplicates? Only when you notice performance drops? A logarithmic calculation? Other considerations or viewpoints?

I am programmer interested in learning strong positive convention practice, that is why I am asking.

  • 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-15T02:41:04+00:00Added an answer on June 15, 2026 at 2:41 am

    A symbol is basically an immutable, interned string. That means, it can’t be changed in place (e.g. by using gsub!) and it is guaranteed that two usages of the same symbol always return the same object:

    "foo".object_id == "foo".object_id
    # => false
    
    :foo.object_id == :foo.object_id
    # => true
    

    Because of that guarantee, symbols are never garbage collected. Once you have “created” a symbol, it will be kept forever in the current process.

    Generally, you should use symbols when you have a static string, or at a least limited number of them, such as keys in hashes or to reference methods. Using symbols here ensure that you are always getting the same object back.

    With ordinary strings, depending on how you compare them, it is possible that you get different objects back. With ordinary strings it is possible to have two or more that look like they are the same, but are actually not the same (see the example above).

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

Sidebar

Related Questions

According to this post , IDEA uses Osmorc to run OSGi frameworks. It, in
According to http://en.wikipedia.org/wiki/Secure_Shell#Key_management , ssh is vulnerable to man-in-the-middle attack when establishing the first
According to the Google App Engine documentation, writing to one entity group is limited
According to Xeround's Release Notes they don't support save points and I can't figure
According to its homepage, the SemWeb library (great library for handling RDF under .NET)
According to Albahari brothers[Page No.273] , IEnumerable is used because: By defining a single
According to docs numpy's default behaviour is to index arrays first by rows then
According to my previous question integration of jsf2.0 and spring 3.1 and hibernate 4.1
According to the C++11 standard, is the following program well-formed and portable C++? int
According to this SO post: How to check the TEMPLATE_DEBUG flag in a django

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.