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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:50:28+00:00 2026-06-01T11:50:28+00:00

I have a C++ code which has 3 array declarations. float A[NUM]; float B[NUM];

  • 0

I have a C++ code which has 3 array declarations.


float A[NUM];
float B[NUM];
float C[NUM];

When I compile with NUM=512, compilation is fast


time g++ -DNUM=512 trials trials.cpp -lm

0.16s user 0.04s system 94% cpu 0.219 total

However, when I compile with NUM=167772160, it takes more time.


time g++ -DNUM=167772160 trials trials.cpp -lm

7.90s user 0.69s system 99% cpu 8.604 total

I haven’t used C++ in years. I am curious to know why there is a time difference in compilation though the object files after the compilation are of the same size.

  • 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-01T11:50:29+00:00Added an answer on June 1, 2026 at 11:50 am

    This is quite a wellknown conundrum. Somewhere along the way, the actual memory for the array is going to be allocated

    See:
    Linker performance related to swap space?

    It would appear that, as we might have suspected, it looks like ld is actually trying to anonymously mmap the entire static memory space of this array (or possibly the entire program, it’s hard to tell since the rest of the program is so small, it might all fit in that extra 4096).

    Also related:

    • Long compilation time for program with static allocation
    • Strange GCC Behaviour
    • missing optimization in gc: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4131
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a third party C code which has large arrays of type float
I have a 3D array which has a time-series of air-sea carbon flux for
I have some code in C# which has a com wrapper. This com wrapper
I have some code which I think has extra release statements. Is the code
I have a C code in which I have a structure declaration which has
I have code which performs query on Jboss server. It has JNDI based datasource
I have inherited a load of VB6 code which has tons of individual OCX
I have a lot of pieces of code which has to be run one
I have some C# / asp.net code I inherited which has a textbox which
I have a master page in my asp.net MVC project, which has code like

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.