SH> CleanUp; { *VERY* inportant that we clean up after ourselves! }
MC> This is completely untrue. If the program is terminating, it's not
MC> necessary to free up the memory allocated for the program, since all
MC> memory used by the program during its execution is returned to DOS
MC> during TP/BP's normal termination. However, the cleanup processing
MC> _is_ useful for applications which finish with allocated memory and
MC> then _reuse_ such allocated memory - you should free it up, set the
MC> pointer to Nil, and when needed, allocate new Heap memory for what's
MC> then required.
MC> Freeing Heap memory and setting the pointers to Nil at the end of
MC> the program is only wasted code and execution effort.
SH> end.
KF> But it's a good habit to get into, and it helps to track any memory
KF> leaks by comparing available memory before and after. I usually add the
KF> code at least while debugging.
For debugging, yes, but as a general practice to be used in most
cases, no. BD makes a specious assertion there, one which many might
take literally for all their work, and I wanted to set the record
(facts) straight: there's no need to free up the memory allocated during
program processing _at_program_termination_. It accomplishes nothing
insofar as system memory goes, and it's important to dispel this old
rumor - because DOS will reclaim all its memory when the program
terminates.
... This Message Printed on 100% Recycled Electrons
--- OMX/Blue Wave/DOS v2.20
---------------
* Origin: Mike's Place (1:114/307.0)
|