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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:08:14+00:00 2026-05-12T07:08:14+00:00

We allocate memory in C using malloc and in C++ using new. I know

  • 0

We allocate memory in C using malloc and in C++ using new. I know that memory allocated must
be freed or given back to OS using free in C and delete in C++.
If I forgot to use free/delete after allocating memory, it means there will be memory leak.

Now, my question is, is this memory leak only during the time period of execution of program; or is it permanent leak/loss or is it gained again once I restart the system ? What is the internal process actually ? What does memory leak/loss mean exactly?

I would be very grateful if someone could explain this in detail or provide me with some nice references.

UPDATE 1

After reading some answers, I learnt that memory is given back to OS/system after program terminates, if that is so, why everyone needs to care so much about memory leak, and why preventing memory leak is very important ?

UPDATE 2

So, memory leak should be prevented so that the system doesn’t crash due to lack of sufficient memory for allocation purposes ??

UPDATE 3

So, after reading all answers, I realized that memory leak is quiet important issues to prevent system crashes. But, for a beginner like me, how can I be sure if my program is completely free from memory leak. I try to do free,delete if I am using malloc,new but sometimes, it gets messy. Is there any tool or method which I can use to know if my program is doing any memory leak ?

UPDATE 4

After reading answers, I have now understood the importance of memory leak free code, less use of new/delete, more use of STL, learnt new stuffs like RAII,valgrind and good programming practices.
Thanks to all 🙂

  • 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-12T07:08:14+00:00Added an answer on May 12, 2026 at 7:08 am

    It’s per-process. Once your process exits, the allocated memory is returned to the OS for use by other processes (new or existing).

    To answer your edited question, there’s only a finite amount of memory in your machine. So if you have a memory leak, then the major problem is that the memory isn’t available for other processes to use. A secondary, but not negligible, effect is that your process image grows, you’ll swap to disc and performance will be hit. Finally your program will exhaust all the memory in the system and fail, since it’s unable to allocate any memory for itself.

    It’s arguable that for a small process with a short lifetime, memory leaks are tolerable, since the leaked memory will be small in quantity and short-lived.

    Take a look at this resource, for possibly more info than you’ll ever need. What we’re discussing here is dynamic or heap allocation.

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

Sidebar

Ask A Question

Stats

  • Questions 211k
  • Answers 211k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer After sqlite3_prepare_v2, you need to actually execute the statement by… May 12, 2026 at 10:14 pm
  • Editorial Team
    Editorial Team added an answer Since you are running IIS 5.1 you may need to… May 12, 2026 at 10:14 pm
  • Editorial Team
    Editorial Team added an answer this works: if ( !$("#G"+num).is(':disabled') ) { $("#G"+num).attr('checked', $("#all_"+num).is(':checked')); }… May 12, 2026 at 10:14 pm

Related Questions

Friends In our C++ , Iam current using realloc method to resize the memory
In the future, will managed runtimes provide additional protections against subtle data corruption issues?
Background: I am writing a C++ program working with large amounts of geodata, and
I'm working on kernel design, and I've got some questions concerning paging. The basic

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.