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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:41:28+00:00 2026-05-27T15:41:28+00:00

Possible Duplicate: What REALLY happens when you don't free after malloc? Is freeing allocated

  • 0

Possible Duplicate:
What REALLY happens when you don't free after malloc?
Is freeing allocated memory needed when exiting a program in C

During my first C class, it was drilled into me that I should call free() after malloc() or calloc() as it releases the space after dynamically allocating memory or otherwise it will be gone (I assume until system reboot). However, recently I started reading on various coding sites that this memory will be released back when the program ends.

Which one is the correct statement?

I would look in the official spec, but I have no idea where to get it (tried Googling).

Thanks.

  • 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-27T15:41:29+00:00Added an answer on May 27, 2026 at 3:41 pm

    Really short answer..

    Both of the statements are correct.


    A longer more elaborate one..

    Both of them are correct, when your application fully terminates the allocated memory will (probably) be released back to the system.

    I wrote "probably" since all modern/widely-used OSes will deallocate the memory used, but some primitive systems might not have this "feature" available.

    Because of the above you should always use free to deallocate memory of allocated but unused variables, especially during run-time (otherwise you’ll have a memory leak that might/will slowly eat up all available memory).

    If you wanna live on the wild side and not deallocate memory before the application terminates, that’s fine by me and most people.B ut, please make sure that the platform you are going to run the application in really does release the memory back to the operating system afterwards.


    Regarding looking in the standard ("official spec")

    The standard most often/always leaves out implementation details, therefor there is nothing in there saying what will happen to allocated memory that hasn’t been deallocated when the running application terminates.

    That’s implementation specific, and therefor depends in/on/at what you are running it.

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

Sidebar

Related Questions

Possible Duplicate: What REALLY happens when you don’t free after malloc? When ending a
Possible Duplicate: Use of var keyword in C# I don't really understand why you
Possible Duplicate: C++: why is new needed? Why cant I use malloc to allocate
Possible Duplicate: Difference between e.target and e.currentTarget I don't really understand the difference between
Possible Duplicate: private members in python I've got few variables I really want to
Possible Duplicate: When is a language considered a scripting language? I am really confused
Possible Duplicate: What's the difference between OpenID and OAuth? What is really the difference
Possible Duplicate: jQuery question: what does it really mean? For example, (function (exports, $,
Possible Duplicate: What is a computer programming language? No, really. I've struggled to come
Possible Duplicate: C#: String.Equals vs. == Are string.Equals() and == operator really same? sometimes

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.