Re: What is the reference count for memory

new topic     » goto parent     » topic index » view thread      » older message » newer message
ArthurCrump said...

In the memory allocation routines there is an optional parameter 'cleanup'.
If this is set the memory is released when a reference count reaches zero.
How is the reference count increased and decreased?
Would the reference count reach zero when the allocated memory is used as a parameter to a function or procedure and the call is completed?
The following code is a Windows XP example.

No. The reference count of the variable is decremented when the program leaves the code block that contains the variable. The block could be the routine in which it is defined, or the if/while/for/loop block in which it is defined. The reference count is also decremented when you assign something else to that variable. Of course, if you assign the value of that variable to another variable, then the reference count is incremented.

Matt

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu