If you know that you are going to fill x cells in the vector, it is best to put a value in cell x and then update all the cells. This will allocate the memory to the vector immediately (instead of allocating memory each time a value is added to a new cell).
The allocation of a vector is according to its size.
Using the VecSet function on cell#999 allocates the first 999 cells, even if there are no values in the first 998 cells.
Deallocating the vector is done by updating the vector pointer to NULL().
There is no technique to "release" the vector tail (for example, the last 500 cells from a 1000 cells vector)
Updating with the NULL function causes the loss of the entire vector.
Even if you update the vector with null, it is not clear that the memory will be released immediately. This kind of update leaves a null pointer, and a garbage collector needs to release the memory. In addition, the operating system's behavior will most likely not reduce the size of the process immediately. Working with a vector is similar to working with memory tables in this sense. The same explanation applies for the memory handling of a Magic xpa BLOB field.
To summarize, you cannot reduce the memory consumption simply by updating cell values with zeros or null values. A vector needs to be completely released, and even then the operating system also plays a part in the timing of the memory release.
|