|
From: <rol...@mi...> - 2003-03-01 15:12:46
|
- variables allocated in stack must not (should not ) be deleted
- variables allocated with new och malloc must be free'd
void main( void )
{
int a ; // allocated on stack - no delete!
int* b = new int ; // allocated with new - do delete!
a = 10 ;
*b = 10 ;
...
...
delete b ; // free b!
}
----- Original Message -----
From: "Robson Bernard" <rob...@su...>
To: "C++ Mail List" <dev...@li...>
Sent: Saturday, March 01, 2003 3:47 PM
Subject: [Dev-C++] Memory
> Hi coders,
>
> I have a question that does not want to shut up! When i code a program, do
i
> have to delete all variables before exiting the main function or does the
> operating system cares of free all the memory allocated? If i do not
delete
> the variables before main function and use the program several times, may
it
> cause the system memory to be unavailble?
>
> Any input welcome!
>
> Thanks!
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|