| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Memory matters |
On: 17 Oct 03 13:28:46 Pascal Schmidt wrote to Roger Scudder: > RS> because something will probably be cleaned up when the program ends > RS> doesn't mean it is a good idea to make it a way of life. :-) > Yeah sure, but there are exceptions. I have a small scene rendering tool which > uses data structures like this: > - top is a scene_t > - this has a linked list of filter_t and a linked list of element_t > - a filter_t includes a linked list of when_t > - an element_t includes a linked list of filter_t > This stuff is constructed by reading an XML scene description at startup, with all > the list elements dynamically allocated. After that, the data never changes while > the program runs. I have not bothered with writing code to traverse three levels > of linked lists and freeing all the element structures. To me there is no exception. I would write the cleanup code. If you compiled you code using a memory diagnostic library I am sure it would flag the lack of matching calls to free. Obviously we have differing opinions here. I don't think that the startup code, or the OS, or the libraries do cleanup as a service to the programmer to make things easier on him. I think they do it because they were written to be robust. A robust system makes sure that it has checked for things like memory leaks and tries to correct them. Robust code doesn't leave loose ends hanging for the next piece of code to clean up. If that is the way you choose to write code, that's on you. I just don't like to do it that way. In a way it's a philosophical thing. My philosophy is this; never make assumptions, and leave things the way you found them. -Roger --- Spinone v0.1.79 Win32* Origin: Scudder's Point (1:261/38.11) SEEN-BY: 633/267 270 @PATH: 261/38 123/500 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™.