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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:33:40+00:00 2026-06-18T09:33:40+00:00

I know that if I don’t free allocated memory with delete/free I’d end up

  • 0

I know that if I don’t free allocated memory with delete/free I’d end up with memory leaks. My question is: if my program gets terminated, does the operating system free the memory for me even if I didn’t?

  • 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-18T09:33:41+00:00Added an answer on June 18, 2026 at 9:33 am

    Whether the memory leaks or not depends on the Operating system. In case of most operating systems once the process in which your program runs exits the OS simply reclaims back the memory it allocated to the process.

    There is another important aspect to it. new results in calling of the class constructor and delete results in call to an destructor. So if you called new and never called delete then in addition to the so called memory leak which may/may not exist after the program exit there is an additional condition that if the destructor of the particular class invokes some code which has side effects then it results in Undefined Behavior.

    So the answer is it depends, You may possibly have:

    • A memory leak(depending on the OS behavior)
    • An undefined behavior(depending on whether code in destructor has side effects)

    C++11 Standard 3.8 Object lifetime:
    Para 4:

    A program may end the lifetime of any object by reusing the storage which the object occupies or by explicitly calling the destructor for an object of a class type with a non-trivial destructor. For an object of a class type with a non-trivial destructor, the program is not required to call the destructor explicitly before the storage
    which the object occupies is reused or released; however, if there is no explicit call to the destructor or if a delete-expression (5.3.5) is not used to release the storage, the destructor shall not be implicitly called and any program that depends on the side effects produced by the destructor has undefined behavior.

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

Sidebar

Related Questions

The example below, is just an example, I know that I don't need an
I know that The Treeset Sort the input automatically but don't accept duplicates.Is there
I know that can't use left join in indexed view. but I don't understand
I know that their are questions and articles about WCF deployment, but i don't
I know that %s is a string of characters, but I don't know how
I don't have any prior experience with Selenium/WebDriver tests. I know that Play supports
Given that I don't know at deployment time what kinds of system my code
Other than that I don't know if I can reproduce it now that it's
I must admit that I don't really know if this is the right place
So I have a problem that I don't really know how to go about.

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.