Announcement

Collapse
No announcement yet.

problem with STATIC variables?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Michael Mattias
    replied
    Fascinating.

    Leave a comment:


  • Cliff Nichols
    replied
    "the next generation"
    Methinks that would pertain to any Trekker, that came Before/During/After Trekkie

    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:


  • Michael Mattias
    replied
    Just like everything else in Windows, "next" is VIRTUAL.

    Leave a comment:


  • Mark Farrar
    replied
    next gen?

    next generation?

    LOL

    I'm 46

    Leave a comment:


  • Michael Mattias
    replied
    Thank goodness at least one of "the next generation" actually thinks about this kind of thing!

    Leave a comment:


  • Mark Farrar
    replied
    thanks

    thanks ...this is what I hoped it would be...

    makes sense...
    M

    Leave a comment:


  • Chris Holbrook
    replied
    Originally posted by Mark Farrar View Post
    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.
    try it : ? varptr(mystaticvar)

    Leave a comment:


  • Michael Mattias
    replied
    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:


  • Mark Farrar
    started a topic problem with STATIC variables?

    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?
Working...
X