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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:24:02+00:00 2026-05-18T02:24:02+00:00

If I have allocated some amount of memory via ::operator new(nbytes) and later I

  • 0

If I have allocated some amount of memory via ::operator new(nbytes) and later I have constructed in this pool via “new (where) what” some number (but lesser than nbytes) of objs of appropriate type, is there a way to check where is the uninitialized memory starts?

Example

struct T{};
short noOfObj = 10;
T* p = static_cast<T*>(::operator new(sizeof(T) * noOfObj));
for (short i = 0; i < (noOfObj - 2); ++i)//here I'm constructing two less obj than available mem
{
new (p + i) T();
}

How could I check (not knowing by how much noOfObj has been decresed) where uninitialized memory pointed by p starts? (feel like I’ve screwed grammar again but I’m afraid that the best I can do for now)

  • 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-05-18T02:24:03+00:00Added an answer on May 18, 2026 at 2:24 am

    wow… ok, trying to battle through this question…

    It seems like you are on about doing your own memory management… such as requesting a huge array of chars to get a big block of memory under control of your program then using this to initialise your own variables, but you want to know what you have given to variables and what is still free.

    Unless you keep track of what memory you have assigned and what you have not assigned, or keep track of every object you assign into this memory pool, no. As far as the OS will be concerned, it gave you that huge block of memory for chars (or what ever basic type you use).

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

Sidebar

Related Questions

Hi I'm writing some test stuff to see the amount of memory that allocated
Lets say I have allocated some memory in my background thread, that is, a
I have allocated a chunk of memory of type char and size is say
In my freeglut project, i have allocated alot of memory, and i have no
I got a table where in got allocated space of 3gig but have no
It's been quite some time, I have been programming in C/C++, but some areas
I have a class where I allocate some memory. For Example: class image {
I have a function called PreProcessSource, which allocates a boost::wave::context and does some preprocessing;
I have an int array for which i have allocated space for 100 elements.
Let's say I have a pointer allocated to hold 4096 bytes. How would one

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.