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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:15:12+00:00 2026-06-05T17:15:12+00:00

I know what RAII does. It is all about preventing memory leaks etc. when/if

  • 0

I know what RAII does. It is all about preventing memory leaks etc. when/if a code throws an exception.

Now, I wish to understand the meaning of that smart term.
http://en.wikipedia.org/wiki/Acquisition

Acquisition means acquiring something.

So, when we say that resource acquiring is initialization, what does that mean?
I am just talking about the meaning of the term here, not about the concept in general.

  • 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-05T17:15:13+00:00Added an answer on June 5, 2026 at 5:15 pm

    It has been said before (possibly by Scott Meyers, I can’t remember), that RAII should be called “Destruction is resource release”, or words to that effect.

    What “resource acquisition is initialization” literally means is that when an object is constructed (initialized), it acquires some resource (such as a memory allocation or a lock). In other words, it says you should only ever acquire a resource, by initializing some object whose destructor will release it.

    This is important to stress because it’s a departure from C coding style, where you acquire resources by whatever means a particular API provides (for example malloc(), accept(), or pthread_mutex_lock()), and release them by explicitly calling the corresponding function (for example free(), close(), pthread_mutex_unlock()). The presence of exceptions in C++ makes this approach fairly unworkable. Even in C it results in some tedious code that every use of the API has to write out, and every user has to ensure that control always passes through that code after they’re finished using the resource.

    But the important part of the pattern is that when the object is destroyed, it releases that resource. It doesn’t actually matter whether you acquire the resource by initializing the object, or by doing something else with the object after it has been initialized. And people will still refer to an object as a “RAII object” when there are operations other than initialization that generate the resource(s) managed by the RAII object.

    So, don’t worry too much about the “acquisition is initialization” in “RAII”, because anyway it’s slightly misleading.

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

Sidebar

Related Questions

I know this is fairly subjective, but I'm diving into testing and learning about
I know this is a stupid question, but I've looked for 45 mins now
I know very little about Agile but I wonder if there is any difference
I know that there's something fishy about the malloc part, but I'm having trouble
Know of a way to mock %[]? I'm writing tests for code that makes
I know how to slice array with numpy, for example v[1, :, :] now
Know anybody something about hooking __userpurge type of functions? I hooking successfully __thiscall ,
I know threre a lot of libraries dotnetopenauth,oauthbase, etc. But i need sample of
We allocate memory in C using malloc and in C++ using new. I know
Know anybody something about hooking __usercall type of functions? I hooking successfully __thiscall ,

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.