WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Pointers

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Reclaim Memory Storage from PtrPersistent

 Keywords: Variable Pointer Memory Storage Drop DropWild 

Question:

I have a question about reclaiming storage of things that were created by a PtrPersistent statement. If I create a pointer to a variant array like this:
fred = PtrPersistent(sally, objRS.GetRows())
and then later want to drop that array and reuse the memory, what's the right way to do it? "*fred = 0" executes, but did it reclaim the storage?

Answer:

Yes. Either of the following will reclaim the memory stored in that safearray:
Drop(*fred)  ; reclaim the storage
Or
*fred = 0  ; reclaim the storage
Note: A WinBatch pointer is really just a string. But if you are concerned about it, you can set the pointer variable to zero to cause an error when subsequently dereferenced. However, doing that could cause loss of access to the 'thing' pointed to. WinBatch pointers are not the same thing as C/C++ pointers. C/C++ pointer point to chucks of heap or stack memory. WinBatch pointers are just a different way of referring to a WinBatch variable someplace in the variable table.

If you wanted to reclaim the storage AND the variable slot, the following lines are needed

Drop(*fred) ; reclaim the storage
Drop(fred)  ; reclaim the variable slot

Article ID:   W18223
Filename:   Reclaim Memory Storage from PtrPersistent.txt
File Created: 2009:07:07:08:52:32
Last Updated: 2009:07:07:08:52:32