The SHMDEBUG function enables a debugging mode in which IDL prints an informational message (including a traceback) every time a variable created with the SHMVAR function loses its reference to the underlying memory segment created by. There are many reasons why a such a variable might lose its reference; some reasons have to do with the internal implementation of the IDL interpreter and are not obvious or visible to the IDL user.
Note: The SHMDEBUG debugging mode should be used for problem solving only, and should not be part of production code.
Create a memory segment, tie a variable to it, enable debugging, and then cause the variable to lose the reference:
old_debug = SHMDEBUG(1) ; Enable debug mode
SHMMAP, 'A', 100 ; 100 element floating vector
z = SHMVAR('A') ; Variable tied to segment
z = FINDGEN(100) ; Does not lose reference
z = FINDGEN(100) ; Loses reference
% Variable released shared memory segment: A
% Released at: $MAIN$
The assignment z = FINDGEN(100) explicitly uses subscripting to assign the FINDGEN value to the array. Under normal circumstances, using subscripting in this way on the left hand side of an assignment is inefficient and not recommended. In this case, however, it has the desirable side effect of causing the variable Z to maintain its connection to its existing underlying memory. In contrast, the second (normally more desirable) assignment without the subscript causes IDL to allocate different memory for the variable Z, with the side effect of losing the connection to the shared memory segment.
Result = SHMDEBUG(Enable)
SHMDEBUG returns the previous setting of the debugging state.
Set this argument equal to a non-zero value to enable debugging, or to zero to disable debugging.