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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:03:55+00:00 2026-05-20T08:03:55+00:00

1) Is MMGR thread safe? 2) I was hoping someone could help me understand

  • 0

1) Is MMGR thread safe?

2) I was hoping someone could help me understand some code. I am looking at something where a macro is used, but I don’t understand the macro. I know it contains a function call and an if check, however, the function is a void function. How does wrapping “(m_setOwner (FILE,_LINE_,FUNCTION),false)” ever change return types?

#define someMacro (m_setOwner(__FILE__,__LINE__,__FUNCTION__),false) ? NULL : new ...
void m_setOwner(const char *file, const unsigned int line, const char *func);

3) What is the point of the reservoir?

4) On line 770 (“void *operator new(size_t reportedSize)” there is the line
“// ANSI says: allocation requests of 0 bytes will still return a valid value”

Who/what is ANSI in this context? Do they mean the standards?

5) This is more of C++ standards, but where does “reportedSize” come from for “void *operator new(size_t reportedSize)”?

6) Is this the code that is actually doing the allocation needed?
“au->actualAddress = malloc(au->actualSize);”

  • 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-20T08:03:55+00:00Added an answer on May 20, 2026 at 8:03 am

    1) The C++03 standard does not mention threads. However, in all platforms with thread support I know of, the default memory allocator (new and delete) is thread safe.

    Edit: In general, if things are not marked as thread-safe, you should assume they aren’t, especially when there implicit global data (such as heap management structures in a memory manager). I’ve read some comments on another forum about this MMGR library not being thread safe.

    2) The comma operator in the macro discards the result on the left, so the result of the (m_setOwner(...), false) expression is always false.

    Edit: This syntax is used in MMGR to log the memory allocation before proceeding to the real allocation. The comma operator is used so that the new macro syntax is unchanged. Pre-processor macros are a simple text-based find-and-replace mechanism. Any use of new in your code will compile with or without this MMGR library. Just that, when using MMGR, the memory allocation will be logged, which is useful for debugging!

    3) What “reservoir”? Are you referring to the heap? Where did you get this term from?

    Edit: The memory manager at the application level is just a front-end to the memory manager at the system level. Hence, it must ask the system to allocate large pages of memory. The reservoir, in this case, seems to be the name for the mechanism that pre-allocates some of those large pages such that the next few allocations are guaranteed to succeed. This is mainly an optimization, as you amortize the cost of a single (expensive) system-level allocation over several application-level allocations.

    4) Yes, “ANSI”, in this context, refers to the the C++03 standard. The proper way to refer to it now is to use the ISO standard number. Feel free to Google it.

    5) The reported size is set by the compiler. When you write something like X* x = new X(...); the compiler logically “rewrites” this to the equivalent form:

    X* x = static_cast<X*>(operator new(sizeof(X)));
    new(x) X(...);
    

    The first line allocates enough memory (sizeof(X) is the value passed as the reportedSize argument to operator new). The second line invokes the constructor of the X class to create an object in the allocated slot of memory.

    6) See #5. Yes, can think of it in these temrs, although your platform will likely not call malloc() in the operator new in “release” mode.

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

Sidebar

Related Questions

I finished my little project that does some heavy lifting. i realized in this
I create a QFuture that I want to use to parallelize calls to 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.