X
77 Rate this article:
No rating

INTERNAL: Size in memory of an IDL pointer variable

Zachary Norman

Beginning with IDL version 5, IDL includes a new pointer data type to facilitate the construction of dynamic data structures.

Pointer variables are not directly usable by many of the operators, functions, or procedures provided by IDL. You cannot, for example, do arithmetic on them or plot them. You can, of course, do these things with the heap variables referenced by such pointers, assuming that they contain appropriate data for the task at hand. Pointers exist to allow the construction of dynamic data structures that have lifetimes that are independent of the program scope they are created in.

The question arise then, what is the size in memory of a pointer variable?, and how it depends on the operating system architecture.

Discussion
The pointer itself is just a regular IDL_VARIABLE, so it takes up 20 bytes on a 32-bit machine, or 24 bytes on a 64-bit machine.

Then there is the actual IDL_HEAP_VARIABLE (the variable pointed to by the pointer), which has some flags and pointers in it, as well as whatever size it needs to hold the variable value - for a scalar value this takes up either 36 bytes for 32-bit or 48 bytes for 64-bit. If you are pointing to an array or structure it would obviously take up more.