Announcement
Collapse
No announcement yet.
problem with STATIC variables?
Collapse
X
-
"the next generation"
Current Gen....lets chalk that up to DS9
Younger Gen but just now getting there....count as Voyager
And the kids that already show promise (even at 3 or less) I count as "ENTERPRISE"
Leave a comment:
-
Thank goodness at least one of "the next generation" actually thinks about this kind of thing!
Leave a comment:
-
thanks
thanks ...this is what I hoped it would be...
makes sense...
M
Leave a comment:
-
Originally posted by Mark Farrar View PostSo...does it overwrite this one location each time the function is called or does it allocate a new spot in memory each time the function is called.
Leave a comment:
-
STATIC and GLOBAL variables are allocated once, when the program starts, by the compiler (you do nothing).
Their values may change ("overwritten") , but they are never re-allocated. No leaking.
Leave a comment:
-
problem with STATIC variables?
In looking at passing an ASCIIZ PTR back from a function the documentation says that you should declare the corresponding variable in the function as GLOBAL or STATIC. I think this makes sense since when the function terminates you still want the pointer you passed to still point to something. OK...
The question is does this create a memory leak?
Every time I call the function it creates a STATIC variable. If I read this correctly the variable (actual data in mem) remains when the function ends and stays viable as long as the program is running. So...does it overwrite this one location each time the function is called or does it allocate a new spot in memory each time the function is called.
If the latter is true, then would not you eventually eat up memory each time you call the function?
So...does calling a function with STATIC variables effectively create a memory leak?Tags: None
Leave a comment: