943,699 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 1669
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Jan 26th, 2009
0

what happens if i dont delete the object?

Expand Post »
i wonder if i create an object from a class using new operator, and if i dont delete that object when i am finished using it, does it still remain in the memory after the program reaches the and of the main function?
Thanks
Similar Threads
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Jan 26th, 2009
0

Re: what happens if i dont delete the object?

Yes, it does remain. If new operator is used u need to delete explicitly.
Reputation Points: 36
Solved Threads: 5
Newbie Poster
da penguin is offline Offline
18 posts
since Dec 2008
Jan 26th, 2009
0

Re: what happens if i dont delete the object?

Click to Expand / Collapse  Quote originally posted by da penguin ...
Yes, it does remain. If new operator is used u need to delete explicitly.
how do you know it remains?
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Jan 26th, 2009
3

Re: what happens if i dont delete the object?

Click to Expand / Collapse  Quote originally posted by da penguin ...
Yes, it does remain. If new operator is used u need to delete explicitly.
What the **** are you talking about? When the program ends, nothing remains.
Team Colleague
Reputation Points: 1133
Solved Threads: 171
Super Senior Demiposter
Rashakil Fol is offline Offline
2,478 posts
since Jun 2005
Jan 26th, 2009
0

Re: what happens if i dont delete the object?

Now, when u asked, i don't know how i know but i know if u know what i mean.
Reputation Points: 36
Solved Threads: 5
Newbie Poster
da penguin is offline Offline
18 posts
since Dec 2008
Jan 26th, 2009
0

Re: what happens if i dont delete the object?

What the **** are you talking about? When the program ends, nothing remains.
huh?
Reputation Points: 36
Solved Threads: 5
Newbie Poster
da penguin is offline Offline
18 posts
since Dec 2008
Jan 26th, 2009
1

Re: what happens if i dont delete the object?

It doesn't remain "in memory" because the process has completed and all of its memory is reclaimed by the operating system.
Team Colleague
Reputation Points: 1133
Solved Threads: 171
Super Senior Demiposter
Rashakil Fol is offline Offline
2,478 posts
since Jun 2005
Jan 26th, 2009
0

Re: what happens if i dont delete the object?

It doesn't remain "in memory" because the process has completed and all of its memory is reclaimed by the operating system.
That was what i thought too.
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Jan 26th, 2009
0

Re: what happens if i dont delete the object?

Well that depends on your OS.

Your average desktop with an OS which runs each process in a separate address space will reclaim the space when the program exits.

But if you're programming on say a mobile phone, where there is no virtual memory, and not a lot of operating system, then a thread which dies will just leave a big mess in memory with no clear way of fixing it.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Jan 26th, 2009
0

Re: what happens if i dont delete the object?

so it is a good habit to delete objects that are created by the new keyword although it may not cause problems in some cases.
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: need help in lib management project
Next Thread in C++ Forum Timeline: Simple pointer program crashses





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC