|
From: Ioannis V. <no...@ho...> - 2003-03-01 16:09:18
|
-------Original Message-------=0D =0D From: Robson Bernard=0D Date: =D3=DC=E2=E2=E1=F4=EF, 1 =CC=DC=F1=F4=E9=EF=F2 2003 4:50:31 =EC=EC=0D To: C++ Mail List=0D Subject: [Dev-C++] Memory=0D =0D Hi coders,=0D =0D I have a question that does not want to shut up! When i code a program, d= o i=0D have to delete all variables before exiting the main function or does the= =0D operating system cares of free all the memory allocated? If i do not dele= te=0D the variables before main function and use the program several times, may= it=0D cause the system memory to be unavailble?=0D =0D Any input welcome!=0D =0D =0D =3D=3D> When the program terminates, the OS releases all the allocated me= mory, both on the stack & the free store. However, it is a bad habbit to do not free allocated memory on the free store, when you do not need it anymore, because till it terminates you are losing avaiable memory. For example th= ere are programs that run all the time in a loop or something, minimized, dedicated systems etc where you do not close the application.=0D =0D On a garbage collected system (like .NET for example but there are others too), you do not need to free explicitly the allocated memory on the free store, since the GC engine undertakes this task and frees unused memory w= hen it needs more. However even in these systems i prefer to deallocate memor= y explicitly.=0D =0D =0D =0D Ioannis Vranos=0D =0D * Programming pages: http://www.noicys.freeurl.com=0D * Alternative URL: http://run.to/noicys=20 |