TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: All
from: Kurt Kuzba
date: 2003-10-16 17:16:06
subject: Memory matters

From: kkuzba{at}centurytel.net
To: c_echo{at}yahoogroups.com

* Author: Bo Simonsen
BS>  In my file ticker, I'm reading the configuration into a
BS>  structure.. This structure do I need all the time, so I
BS>  figured is it nessersary to free it then I'm ending the
BS>  program?

    If you are using dynamic allocation, then you should use the
 free() function to release the memory back to the OS before you
 exit the program.  If you are in DOS, and perhaps in some of the
 other available operating systems, all memory allocated during
 the program run will be returned whether you give it back or not.
 Under Windows, though, it may not, so that system memory remains
 allocated and is unavailable for future use.  Allocating memory
 whenever needed without ever freeing it can also constitute a
 memory leak during runtime, even under DOS.  In that case, it may
 cause the program to fail, but it will not seriously effect the
 ability of the OS to continue operations.  If it is only one
 structure, then you might prefer to use a static variable or a
 global variable, which will automatically be removed when the
 program is exited.  In your case, since you only need one instance
 of the struct, and it is used throughout the program, you would
 probably just want to allocate it first thing and then free() it
 just before exiting.

>  kkuzba{at}centurytel.net   http://home.centurytel.net/kkuzba
>  'They did not die!' said Treebeard. 'I never said they died.'

--- SoupGate-Win32 v1.05
* Origin: kkuzba{at}centurytel.net (2:292/516.666)
SEEN-BY: 633/267 270
@PATH: 292/516 854 140/1 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.