True, still, that's a leak that will be cleaned up by the OS, not that serious on modern OSes, and not as big of an issue since it's not in a function called often. (main() can't be called in C++)
That's still a bit shady practice to not do a cleanup. +1
OP: you should always remember that if you use new/new[] - you need to use delete/delete[] to free the memory. Unless, of course, you use smart pointers, in which case the smart pointer will use delete for you, when the time comes.
16 Replies - 2718 Views - Last Post: 05 June 2011 - 12:38 PM
#17
Re: Sorting words, stuck in infinite loop.
Posted 05 June 2011 - 12:38 PM
vividexstance, on 05 June 2011 - 11:38 AM, said:
Did no one see my post, or see how the OP's code has a memory leak in it? When you use dynamic memory allocation(using the new operator), there needs to be a delete statement somewhere to delete the memory you allocated with the new operator. If you don't, you will end up with a memory leak which is a serious issue.
I gotcha buddy, I put it in my updated code and your point is earned =)

New Topic/Question
Reply




MultiQuote


|