RE: Penalty for using globals?
- Posted by rudy toews <rltoews at ilos.net> Jun 14, 2002
- 376 views
SR.Williamson wrote: > What kind of penalty can I expect from using a lot of global variables > or sequences? Speed? Memory use? > > > if you define a variable inside a function , it exists while that function is running. it is deleted from the programs 'address' space when that function is finished. you would probably get a penalty in time if you are frequently creating and destroying the same variable. if you define it outside all your functions , it uses some address space while your program runs but is available to any of the functions that need it at any time. thats where the programmer has to make compromised performance decisions. each program(problem) has it own factors to determine the best direction to go. just like having to decide to hold data in memory or on disk while program is running. not everyone has the same amount of memory in their system so your program might run fine on your system but crash on their system if you make everything stay in memory. hope this helps somewhat. later rudy rltoews at ilos.net lotterywars