Is there a way to release the memory used by the makeTable() function? If you assign nil to the variable holding the table object, will the table be deleted and the memory freed?
I would like to use makeTable in a pcell, however I'm worried about using too much memory if the table data is always around and duplicated wherever the pcell is used.
I could use remove(g_key o_table) on every element.
You may be aware that garbage collection is the process by which unused memory is reclaimed. There are various ways that memory can become unused, for example, it was allocated in a let statement and this block of code has been executed and exited, or as you state, by effectively removing references to the memory. Once all references to a chunk of memory have been removed, it is liable for garbage collection. This process occurs every so often, but can be initiated by the user also, using the gc() function. See the following section in the SKILL Language User Guide in SourceLink: "Memory Management (Garbage Collection)"
I would recommend using an encapsulation technique when writing your PCell code, so that the code that does all of the work is encapsulated in a procedure which can be debugged outside of the PCell development, and also potentially re-used by other PCells. Something like the following:
list( ddGetObj("libName") "cellName" "layout")
( paramA 1.0 )
( paramB 2.0 )
myPCellTopFunction( pcCellView paramA paramB )
Hopefully the above information and pointers will help you.
In reply to skillUser:
Also be aware that when you pass a table as an argument, you are passing a pointer to the table and not the values in it. So if you change a value in the table inside a program where it came in as an argument, you change the table itself.
HOWEVER- It is much faster and takes less memory to pass the table as an argument than to pass the very large list of individual arguments. If your table variable is defined in a let statement, it will be garbage collected when it finally goes out of scope.