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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:19:59+00:00 2026-05-12T10:19:59+00:00

In order for an application to have no memory leaks, does the number of

  • 0

In order for an application to have no memory leaks, does the number of new in a C++ project match the number of delete?

  • 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-12T10:19:59+00:00Added an answer on May 12, 2026 at 10:19 am

    If you mean do you need the same number of instances of delete in your source code as you have instances of new, then no. You can have objects newed in multiple places, but all these objects deleted by the same line of code. In fact this is a common idiom.

    Smart pointers, of varying types, generally take many different objects newed in many places in user code and delete them from a single place in library code.

    Edit

    Technically, every successfully memory allocation call needs to be matched with a dellocation call that takes the returned pointer from the original allocation call.

    Most new expressions result in a call to an operator new that allocates the memory and the constructs an object in the newly allocated memory. Using a delete expression destroys the object and causes a call to an operator delete that should free the allocated memory.

    There are new expressions that construct objects in pre-allocated memory (placement new). These should not be matched by a delete expression, but the pre-allocated memory may need to be deallocated in a way that corresponds to the original allocation.

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

Sidebar

Related Questions

My .net application does some heavy string loading/manipulation and unfortunately the memory consumption keeps
Can I use shared memory on Windows in order to have a common memory
I am trying to work out some memory leak issues in an application, and
I have a server application that, in rare occasions, can allocate large chunks of
In order to find more easily buffer overflows I am changing our custom memory
I'm trying to diagnose a PermGen memory leak problem in a Sun One 9.1
I am trying to develop a Windows Mobile 6 (in WF/C#) application. There is
I'm loading in content using an iframe via a menu with jquery which is
I am looking for a way to cure at least the symptoms of 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.