Board index » delphi » Questions

Questions

Hi,

I have simple questions for you guys.

1. What is better for saving memory? Declaring an integer (for
iteration) variable in every functions and procedures or just declaring
one and share throughout the program?

2. Is there any way to check the memory usage of a program to
determine the program's memory requirement.

Any hint will be much appreciated,

Thanks

Aek

 

Re:Questions


Quote
>1. What is better for saving memory? Declaring an integer (for
>iteration) variable in every functions and procedures or just declaring
>one and share throughout the program?

Loop variables that are used locally within a procedure should be
declared in that function. This way the memory for the variable
is only allocated when the procedure is called, and the memory
is freed when the procedure finishes.

It is also possible that using a single global variable for all
loops could introduce strange bugs that would be quite hard to
track down.

Quote
>2. Is there any way to check the memory usage of a program to
>determine the program's memory requirement.

There are quite a few commercial/free/shareware memory checking
products - search DejaNews in this group for previous disussions. The
Windows NT Task Manager (if you're running NT) will also give you some
clues.

But please, don't neglect *real testing* on various machines. Remember
that MS claimed that Windows 95 would run fine on a 486 with 4MB of
memory? That may have been true in theory, but in practice it was
nonsense.
--
Jeremy Collins
Kansai Business Systems

(return address not altered 'coz I get spammed *whatever* I do!)

Other Threads