Armando,
 
Memory associated with GISDK macro variables is freed when the variables are 
set to null or when the macro exits.  The only exceptions to this is when the 
value is stored in a shared, static or a global variable, then the value 
persists throughout the session and will not be freed until the shared variable 
is set to null.  If that is not done, it persists until the program shuts down.
 
How you resize your arrays can affect memory performance.  As you note, myArray 
= myArray + {value} is slower than using dim[].  In the end, the same 
theoretical amount of memory would be used.  However, there might be some 
memory fragmentation taking place as a result. 
 
I see you are familiar with vectors.  I would encourage you to use them as they 
are more efficient than arrays.  Since all the vector elements are of the same 
type, less memory is used for every element (the type information only needs to 
be stored once for the vector, instead of once for every element).  And the 
vectors offer many very efficient operations.  You can add them (v3 = v1 + v2), 
use them in conditional expressions (w = if v>0 then 1 else 0) and you can pass 
them to functions (w = 1+sin(v)).  In many cases a single statement can replace 
a potentially slow GISDK loop on arrays.
 
-Kjartan
 
From: [email protected] [mailto:[email protected]] On Behalf Of 
Armando Scalise
Sent: Monday, February 21, 2011 12:19 PM
To: [email protected]
Subject: [Maptitude] Garbage colleciton and memory management in GISDK
 
  
I wonder wehter someone in Caliper could shred some light into memory mangement 
and garbage colleciton in GISDK
 
I am bumping into memory issues in a macro that handles very large  (millions 
of records) multidimensional arrays.
 
My initial macro had a number of those arrays defined, so I splitted the code 
and use the vectors one at a time in separate macros.  The memory issues still 
persist
 
Before rewriting my code to a disk-based data management as opposed to using 
memory arrays. I would very much appreciate if you could provide some input on 
the folloiwng  questions:
 
     - Does GISDK frees up all the memory macro uses (for exmaple, arrays that 
are only used within the macro and not passed back as ouput) once the macro is 
terminated?
     - If so, when does this happen?  immediately after the macro is finished? 
or randomly?
     - If I have a large array in a macro, and I set it to null before leaving 
the macro, does that liberates memory immediately?
     - Does an expression like  myArray  = myArray + {newvalue} when used 
recursively  imposes a toll on memory usage?  (I know that Dim myArray[n] is 
more efficient, but often times I ignore the dimension the array will end up 
having)
     - Are there any specific guidliness or reccomendations for  using large 
arrays in the DK?
 
Thanks
 
-- 
Armando Scalise

Reply via email to