POV-Ray : Newsgroups : povray.off-topic : c++ memory question : Re: c++ memory question Server Time
11 Oct 2024 11:10:13 EDT (-0400)
  Re: c++ memory question  
From: Fredrik Eriksson
Date: 2 Oct 2007 18:55:05
Message: <op.tzldx8fmcs6ysw@e6600>
On Wed, 03 Oct 2007 00:50:20 +0200, Samuel Benge  
<stb### [at] THIShotmailcom> wrote:
> Fredrik Eriksson wrote:
>>  No. Indeed, you must not, as it is not dynamically allocated.
>>
>>> Is the memory used by that array freed after the program is terminated?
>>  It is freed when 'i' goes out of scope. If 'i' is in namespace scope,  
>> it goes out of scope when the program ends.
>
> Thank you. My program should not have any memory leaks, then. I assume  
> this also applies to other variables as well?


Only objects that are dynamically allocated - i.e. with 'new' - need to be  
explicitly deallocated. You may not need to use 'delete' at all if you use  
standard library containers and/or smart pointers.



-- 
FE


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.