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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:48:08+00:00 2026-06-09T15:48:08+00:00

My question is regarding the memory management of a 4GB addressable system char *p

  • 0

My question is regarding the memory management of a 4GB addressable system
char *p = NULL;
Does it occupy any memory?
If so, where in the heap or stack and how much?
Also tell about char **p=NULL;

  • 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-09T15:48:09+00:00Added an answer on June 9, 2026 at 3:48 pm

    On a typical 32 bit system, it takes 4 bytes.

    Assuming your examples are a definition of a local variable in some function, those bytes are taken from the stack. Although:

    • if the variable is not used elsewhere, the compiler may remove it altogether from the generated code;
    • if the variable is used only locally and its address is not taken, it may be put into a register, so it doesn’t occupy “regular” memory.

    If, instead, it’s a global variable (or, in general, a variable with static storage duration), on most systems there’s a special region of memory (separated from the stack and the so-called heap) used for them. Often it’s just a region of memory mapped directly from the executable image in copy-on-write mode. So here the 4 bytes are occupied both in this particular memory area, both in space inside the executable.

    The same holds for char **p, which, in line of principle, has no reason for being bigger or different somehow from char *.


    By the way, if char * p or char ** p were part of an aggregate data type (typically a struct), the space they take comes from wherever the struct is allocated – if the struct variable is a local variable, it comes from the stack, if it’s allocated dynamically with malloc on the heap, if it’s a global it comes from the special memory region for globals. Keep in mind that, talking about space taken by structs, additional considerations about padding come into play.


    Notice that all those are considerations valid for “typical” 32-bit systems; nothing stops some bizarre architecture from making char ** different in size from char * (although I don’t see any reason to do that). Still, you can perform a direct check by using the sizeof operator.

    As far as the standard is concerned, I think that the only constraint imposed to pointer size is that any pointer to data can be converted to and from void * without loss of information (actually, the standard doesn’t ever mention the stack or registers). Also, keep in mind that the compiler is allowed to do anything it wants as far as the “observable behavior” is coherent with what is requested from the standard, so there’s no real guarantee on these implementation details mandated by the standard, although more details may be found in the documentation of the compiler you are using.

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

Sidebar

Related Questions

Quick question regarding memory management in C++ If I do the following operation: pointer
I have a quick question regarding memory management that I am not quite sure
I have a question regarding AS3 memory management I wonder if anyone could help
I have a question regarding some memory management in C. I have to allocate
I have a question regarding the JVM memory management (at least for the SUN's
I have a general question regarding memory management of properties. Currently, I always use
I have a question regarding memory management in objective-c. I have read Apple's various
I have a basic question regarding memory management in TCL. Suppose I have a
I'm new to C++ and have a question regarding memory management. In the header,
I'm very new to memory management, and I have a question regarding saving a

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.