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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:00:32+00:00 2026-06-09T04:00:32+00:00

Possible Duplicate: Why are compiled Java class files smaller than C compiled files? Just

  • 0

Possible Duplicate:
Why are compiled Java class files smaller than C compiled files?

Just out of curiosity I just compiled “Hello Worlds” in C, C++ and Java.

The Java class file comes out very lean at just 423B which I understand since the runtime isn’t included in the binary.

The C and C++ ones are 8.5K and 9.2K however.

Why are they so relatively big?
I always assumed stdio or iostream are linked at dynamically and don’t add to the size of the executable.

So where do all the kilobytes come from?
By looking at the hexdump I see that there’s a lot of padding, I guess for performance reasons. Why exactly is a binary format organized like that?


pmg’s link is very helpful!

Regarding the padding, I found it’s the aligning of the program’s segments to virtual memory page boundaries (4096 bytes) that causes it to be at least 8192 bytes.

Regarding the mach-o binary format (for OS X and iOS)

For best performance, segments should be aligned on virtual memory page boundaries—4096 bytes for PowerPC and x86 processors. To calculate the size of a segment, add up the size of each section, then round up the sum to the next virtual memory page boundary (4096 bytes, or 4 kilobytes). Using this algorithm, the minimum size of a segment is 4 kilobytes, and thereafter it is sized at 4 kilobyte increments.

quoting http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/MachORuntime/Reference/reference.html

I’ll do the research before asking next time 😉

  • 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-09T04:00:33+00:00Added an answer on June 9, 2026 at 4:00 am

    This is a question of what you’re measuring. If it’s the raw executable size, this contains a great deal besides the code for main().

    As we’re using shared dynamic libraries here, a great deal of the size will be accounted for by house-keeping data such as symbol tables, the global offset table and a description of the shared libraries to be linked against – the code of the shared libraries themselves is not in the binary.

    The iostream library is a fairly large, and also has static initialisers – for instance to initialise cout, cerr, and cin objects. This is another thing that object file must contain.

    In reality, most of the extra size is not memory resident when the application runs.

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

Sidebar

Related Questions

Possible Duplicate: Is shifting bits faster than multiplying and dividing in Java? .NET? To
Possible Duplicate: How does a compiled C++ class look like? Hi all, bash$cat struct.c
Possible Duplicate: Why isn't more Java software compiled natively? I know that Java is
Possible Duplicate: Is it possible to view bytecode of Class file? I wanted to
Possible Duplicate: How to lock compiled Java Classes to prevent decompilation ...ideally combined with
Possible Duplicate: Compiler is creating extra class files with $ in them I am
Possible Duplicate: Who calls the main function in java? Consider this code: class abc
Possible Duplicate: Type-parameterized field of a generic class becomes invisible after upgrading to Java
Possible Duplicate: Embedding DLLs in a compiled executable I want to compile my C#
Possible Duplicate: Why won't this generic java code compile? Given the following code: import

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.