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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:11:25+00:00 2026-06-13T01:11:25+00:00

After running the following code: #include <stdio.h> class Nil { }; int main() {

  • 0

After running the following code:

#include <stdio.h>
class Nil
{
};

int main()
{
    Nil* A[20];
    char* B[20];
    for (int i=0;i!=20;i++)
    {
        A[i]=new Nil;
    }

    for (int i=0;i!=19;i++)
    {
        printf("A:%i\n",((int)A[i+1])-((int)A[i]));
    }
    printf("------------------------------------\n",5);
    for (int i=0;i!=20;i++)
    {
        B[i]=new char;
    }

    for (int i=0;i!=19;i++)
    {
        printf("B:%i\n",((int)B[i+1])-((int)B[i]));
    }
    getchar();
}

OUTPUT:

A:7112
A:64
A:64
A:64
A:64
A:64
A:64
A:64
A:64
A:64
A:64
A:64
A:64
A:64
A:64
A:64
A:64
A:64
A:64
------------------------------------
B:64
B:64
B:64
B:64
B:64
B:64
B:64
B:64
B:64
B:64
B:64
B:64
B:64
B:64
B:64
B:64
B:64
B:64
B:64

why is the allocation size always 64?

  • 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-13T01:11:27+00:00Added an answer on June 13, 2026 at 1:11 am

    C++ memory manager handles allocations as it pleases. The gaps are larger than the objects because the manager needs additional information to know what memory is taken and what is free. All the chunks have the same size thanks to memory padding, for greater efficiency. Notice that should you try allocating large objects, the gaps would widen, most likely by multiples of 64. The gaps between allocated objects are the same, because you allocated them in a sequence – stacking new objects is the most simple allocation strategy. Notice that if the allocations weren’t in sequence or if there were ‘holes’ of free memory, the gaps would not be so even.

    The important thing to remember is that all of this is implementation and platform dependent and should not be relied on.

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

Sidebar

Related Questions

I came across a strange phenomena upon running the following code: #include <iostream> class
After running the following code segment, the output is Outer. Inner. Inner. I know
The following output appears after running some rake tasks: Loaded suite /usr/bin/rake Started Finished
I currently have the following ValuesQuerySet object after running the following code: sites =
Similar to this question , after running the following code the browser dialog does
After running the following code everything does as I would like except the folder
I have the following code: int main() { vector<int> v; for(int i = 0;
After running the following SQL statements, you will see that, MySQL has automatically created
When I run make (after running qmake) I get the following error: /usr/bin/ld: cannot
I am getting the following error after running git svn rebase: 'update-index --refresh: command

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.