Next: The Language Bindings
Up: Arrays
Previous: Independent and borrowed arrays
  Contents
The existence of borrowed arrays causes the arrays to deviate from the
normal reference counting pattern. Arrays are reference counted.
An array's resources are reclaimed when the reference count goes to
zero. However, a borrowed array's array element data will disappear
whenever the source of the borrowed data determines that it should
regardless of the reference count in corresponding the SIDL array.
This behavior means that developers should consider any SIDL array
that they did not create themselves, for example incoming arguments to
methods, as potential borrowed arrays. When a method wants to keep a
copy of an array that might be a borrowed array, it should use the
smartCopy method documented below.
Here are some rules of thumb about the use of borrowed arrays:
- The creator of a borrowed array should guarantee that the data for the
borrowed array will exist through the duration of any method calls
using the borrowed array.
- Methods should not return a borrowed array as a return value or
out parameter unless the method can guarantee that the array
element data will be available until the process shuts down.
- There is a neglible performance cost when using smartCopy
when the array is not borrowed, and there is a huge correctness
benefit when the array is borrowed.
Next: The Language Bindings
Up: Arrays
Previous: Independent and borrowed arrays
  Contents
babel-0.8.0
users_guide Last Modified 2003-01-14
http://www.llnl.gov/CASC/components
components@llnl.gov