Difference between revisions of "MemoryInUseBy"

m
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
[[category:Evaluation Functions]]
 
[[category:Evaluation Functions]]
 +
[[Category: Memory management]]
 
[[Category:Doc Status D]] <!-- For Lumina use, do not change -->
 
[[Category:Doc Status D]] <!-- For Lumina use, do not change -->
  
= MemoryInUseBy(variable) =
+
''This function requires Analytica Enterprise or better.''
 
Returns the memory, i.e., number of bytes, currently being used to store the mid and prob values of ''variable''.
 
  
''This function requires Analtyica Enterprise or better.''
+
== MemoryInUseBy(variable) ==
 +
Returns the number of bytes of memory in use to store the mid and prob values of «variable». For example, to estimate the amount of memory used to store results for Variable ''Revenue'':
 +
:<code>MemoryInUseBy(Revenue)</code>
  
This count may not be entirely accurate for several reasons, discussed below.
+
This result may be approximate for the reasons discussed below.
  
==== Shared Sub-Arrays ====
+
=== Shared Sub-Arrays ===
  
Portions of subarrays may be shared between different variables, or even within the same array.  When you evaluate [[MemoryInUseBy]](X) + [[MemoryInUseBy]](Y) when a subarray is shared between ''X'' and ''Y'', the subarray will be double counted, since it will be counted in the result for both ''X'' and ''Y''.
+
A variable may share subarrays with other variables. Hence,  
 +
:<code>MemoryInUseBy(X) + MemoryInUseBy(Y)</code>
  
Portions of subarrays may also be shared within the same array, and in some cases may be shared multiple times.  Analytica utilizes this feature as a form of sparse-array representation, and in such cases the amount of memory consumed by the array may be dramatically smaller than a full dense array with the same number of cells would require.  In Analytia 4.2 and earlier, [[MemoryInUseBy]] counts the amount of memory that a dense array of the given dimensionality would consume.  In Analytica 4.3, [[MemoryInUseBy]] recognizes shared subarrays and tallies that space a single time, better reflecting the actual memory consumed.
+
may overestimate the total memory used, if <code>X</code> and <code>Y</code> share subarrays that get counted in the result for both <code>X</code> and <code>Y</code>.
  
==== Duplicated Text ====
+
Subarrays may also be shared within the same array, and in some cases multiple times.  Analytica uses this feature as a form of sparse-array representation, which may result in a dramatic reduction in memory used relative to a full dense array with the same number of cells.  Similarly, when arrays contain identical text values -- e.g. "Hello World" -- in multiple cells, it often stores the text value only once in memory -- especially if the text originates from the same point in the model. MemoryInUseBy(X) (since 4.3) takes these memory optimizations into account.
  
The block of characters in a text value may be shared by identical text values.  For example, if the text "hello world" appears in two cells, it is possible (but not guaranteed) that the same text block is shared by the two text values, so that the characters "hello world" appear only once in memory.  This will generally be the case if the text originated from the same point in the model.  However, Analytica 4.2 and earlier will count the space consumed by each text character without recognizing cases where the text is shared.  In Analytica 4.3, [[MemoryInUseBy]] will recognize when the same text block is shared within the same array and avoid this double-counting.
+
=== Internal Heap Overhead ===
  
==== Internal Heap Overhead ====
+
Memory allocations involve a certain amount of "heap overhead" -- space used by the underlying execution system to support dynamic memory allocation, not estimated by [[MemoryInUseBy]].  This overhead includes memory used by the Windows operating system, the run-time system, and Analytica's own memory management.  For example, if Analytica needs a block of 120 bytes, the memory management system may reserve 128 bytes (hypothetically) to obtain various efficiencies, plus another 32 bytes of bookkeeping to keep track of what has been allocated.  Heaps are also subject to [http://en.wikipedia.org/wiki/Fragmentation_(computer) fragmentation], in which small blocks of unused memory may exist between active allocations.  The exact numbers for these types of overhead are hard to predict exactly. 
  
All memory allocations involve a certain amount of "heap overhead", which is space used by the underlying execution system to support dynamic memory allocationSome of this overhead is consumed by the Windows operating system, some by the run-time system, and some by Analytica's own memory management subsystem.   For example, if Analytica needs a block of 120 bytes, it will request 120 bytes.  It is possible that the memory management system will reserve 128 bytes (hypothetically) to obtain various efficiencies, and then may add another 32 bytes of bookkeeping to keep track of what has been allocated, etc. The exact numbers vary with circumstances and are extremely hard to predict exactlyNone of this overhead is counted by [[MemoryInUseBy]].
+
=== Local Index Space ===
 +
The space used by local indexes is generally not talliedIf you ask for the space used by array <code>A</code>, which happens to be indexed by a local index <code>A.I</code>, the object <code>.I</code> and its value consumes space which is not talliedThat same space will be shared between all arrays that use that local index.
  
Heaps are also subject to [http://en.wikipedia.org/wiki/Fragmentation_(computer) fragmentation], in which small blocks of unused memory may exist between active allocationsThese drive up the actual amount of memory controlled by a process, even though they are not actively in use.
+
=== Optimization Storage ===
 +
Memory used internally by «LP», «QP» or «NLP» objects is only partially counted (because Analytica has no way of knowing exactly how much memory is being consumed internally by the Frontline Solver).   
  
==== Local Index Space ====
+
=== Intermediate Values during Evaluation ===
 
 
The space used by local indexes is generally not tallied.  If you ask for the space used by array A, which happens to be indexed by a local index ''A.I'', the object ''.I'' and its value consumes space which is not tallied.  That same space will be shared between all arrays that use that local index.
 
 
 
==== Optimization Storage ====
 
 
 
There are also a few things that are not fully counted.  Also, memory used internally by «LP», «QP» or «NLP» objects is not only partially counted (Analytica has no way of knowing exactly how much memory is being consumed internally by the Frontline Solver). 
 
 
 
==== Intermediate Values during Evaluation ====
 
  
 
The result returned from [[MemoryInUseBy]] reflects the amount of memory used by the mid, prob and index values at the time it is called.  When a result is computed, intermediate values may require more space than the final result alone, and in some cases when these intermediates have extra dimensions, this can be dramatically more space.  The space temporarily utilized during computation is not measured by this function, and there is currently no method for accessing the maximum amount of memory consumed during a computation from within Analytica.
 
The result returned from [[MemoryInUseBy]] reflects the amount of memory used by the mid, prob and index values at the time it is called.  When a result is computed, intermediate values may require more space than the final result alone, and in some cases when these intermediates have extra dimensions, this can be dramatically more space.  The space temporarily utilized during computation is not measured by this function, and there is currently no method for accessing the maximum amount of memory consumed during a computation from within Analytica.
  
=== Example ===
+
== See Also ==
 
+
* [[CompressMemoryUsedBy]]
Determine amount of memory used to store results for Variable ''Revenue'':
 
MemoryInUseBy(Revenue)
 
 
 
= See Also =
 
 
 
* Webinar on [[Analytica_User_Group/Past_Topics#The_Performance_Profiler|Performance Profiler]]
 
 
* [[Memory Usage Dialog]]
 
* [[Memory Usage Dialog]]
 +
* [[Memory usage and management]]
 
* [[Controlling When Result Values Are Cached]]
 
* [[Controlling When Result Values Are Cached]]
* [[EvaluationTime#Displayable.2C_non-editable_attributes_of_variables_and_functions|EvaluationTime]] and [[EvaluationTime#Displayable.2C_non-editable_attributes_of_variables_and_functions|EvaluationTimeAll]] attributes.
+
* [[IsResultComputed]]
* [[IsResultComputed]] function
+
* [[EvaluationTime#Displayable.2C_non-editable_attributes_of_variables_and_functions|EvaluationTime]]
* [[CompressMemoryUsedBy]]
+
* [[EvaluationTime#Displayable.2C_non-editable_attributes_of_variables_and_functions|EvaluationTimeAll]]
 +
* [[Analytica_User_Group/Past_Topics#The_Performance_Profiler|Performance Profiler]]

Latest revision as of 19:32, 6 May 2021


This function requires Analytica Enterprise or better.

MemoryInUseBy(variable)

Returns the number of bytes of memory in use to store the mid and prob values of «variable». For example, to estimate the amount of memory used to store results for Variable Revenue:

MemoryInUseBy(Revenue)

This result may be approximate for the reasons discussed below.

Shared Sub-Arrays

A variable may share subarrays with other variables. Hence,

MemoryInUseBy(X) + MemoryInUseBy(Y)

may overestimate the total memory used, if X and Y share subarrays that get counted in the result for both X and Y.

Subarrays may also be shared within the same array, and in some cases multiple times. Analytica uses this feature as a form of sparse-array representation, which may result in a dramatic reduction in memory used relative to a full dense array with the same number of cells. Similarly, when arrays contain identical text values -- e.g. "Hello World" -- in multiple cells, it often stores the text value only once in memory -- especially if the text originates from the same point in the model. MemoryInUseBy(X) (since 4.3) takes these memory optimizations into account.

Internal Heap Overhead

Memory allocations involve a certain amount of "heap overhead" -- space used by the underlying execution system to support dynamic memory allocation, not estimated by MemoryInUseBy. This overhead includes memory used by the Windows operating system, the run-time system, and Analytica's own memory management. For example, if Analytica needs a block of 120 bytes, the memory management system may reserve 128 bytes (hypothetically) to obtain various efficiencies, plus another 32 bytes of bookkeeping to keep track of what has been allocated. Heaps are also subject to fragmentation, in which small blocks of unused memory may exist between active allocations. The exact numbers for these types of overhead are hard to predict exactly.

Local Index Space

The space used by local indexes is generally not tallied. If you ask for the space used by array A, which happens to be indexed by a local index A.I, the object .I and its value consumes space which is not tallied. That same space will be shared between all arrays that use that local index.

Optimization Storage

Memory used internally by «LP», «QP» or «NLP» objects is only partially counted (because Analytica has no way of knowing exactly how much memory is being consumed internally by the Frontline Solver).

Intermediate Values during Evaluation

The result returned from MemoryInUseBy reflects the amount of memory used by the mid, prob and index values at the time it is called. When a result is computed, intermediate values may require more space than the final result alone, and in some cases when these intermediates have extra dimensions, this can be dramatically more space. The space temporarily utilized during computation is not measured by this function, and there is currently no method for accessing the maximum amount of memory consumed during a computation from within Analytica.

See Also

Comments


You are not allowed to post comments.