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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:28:00+00:00 2026-06-06T04:28:00+00:00

On this blog post , it’s said that the minimum memory usage of a

  • 0

On this blog post, it’s said that the minimum memory usage of a String is:

8 * (int) ((((no chars) * 2) + 45) / 8) bytes.

So for the String “Apple Computers”, the minimum memory usage would be 72 bytes.
Even if I have 10,000 String objects of twice that length, the memory usage would be less than 2Mb, which isn’t much at all. So does that mean I’m underestimating the amount of Strings present in an enterprise application, or is that formula wrong?

Thanks

  • 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-06T04:28:01+00:00Added an answer on June 6, 2026 at 4:28 am

    String storage in Java depends on how the string was obtained. The backing char array can be shared between multiple instances. If that isn’t the case, you have the usual object overhead plus storage for one pointer and three ints which usually comes out to 16 bytes overhead. Then the backing array requires 2 bytes per char since chars are UTF-16 code units.

    For "Apple Computers" where the backing array is not shared, the minimum cost is going to be

    1. backing array for 16 chars — 32B which aligns nicely on a word boundary.
    2. pointer to array – 4 or 8B depending on the platform
    3. three ints for the offset, length, and memoized hashcode – 12B
    4. 2 x object overhead – depends on the VM, but 8B is a good rule of thumb.
    5. one int for the array length.

    So roughly 72B of which the actual payload constitutes 44.4%. The payload constitutes more for longer strings.


    In Java7, some JDK implementations are doing away with backing array sharing to avoid pinning large char[]s in memory. That allows them to do away with 2 of the three ints.

    That changes the calculation to 64B for a string of length 16 of which the actual payload constitutes 50%.

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

Sidebar

Related Questions

This blog post of December 2008 says that rubygems is broken on Debian-based systems.
Just finished reading this blog post: http://www.skorks.com/2010/03/an-interview-question-that-prints-out-its-own-source-code-in-ruby/ In it, the author argues the case
Should be an easy one. I thought, from reading this blog post that I
This blog post mentions that XPCOM components will no longer be able to observe
I just read this blog post and it stated that: Google is now working
Jon Skeet posted this blog post , in which he states that he is
I recently came across this blog post which basically says that we should not
It's easy! I just came across this blog post by Rudi Grobler that says
This blog post suggests that it might be possible to play YouTube videos with
This blog post (slightly annoying page there) (and that's not my blog by the

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.