Routines (alphabetical) > Routines: S > SHMUNMAP

# SHMUNMAP

The SHMUNMAP procedure is used to remove a memory segment previously created by SHMMAP from the IDL session. In addition, it may remove the memory segment from the system. (Whether the memory segment is removed from the system depends on the type of segment, and on the arguments used with SHMMAP when the segment was initially attached.) If no variables from the current IDL session are accessing the segment (that is, if the IDL-maintained reference count is 0), the segment is removed immediately. If variables in the current IDL session are still referencing the segment, the segment is marked for removal when the last such variable drops its reference.

During this UnmapPending phase:

- The segment still exists in the system, so attempts to use SHMMAP to create a new segment with the same SegmentName will fail.
- Additional calls to SHMVAR to attach new variables to this segment will fail.

Note: IDL has no way to determine whether a process other than itself is accessing a shared memory segment. As a result, it is possible for IDL to destroy a memory segment that is in use by another process. The specific details depend on the type of memory segment, and the options used with SHMMAP when the segment was loaded. When creating applications that use shared memory, you should ensure that all applications that use the segment (be they instances of IDL or any other application) communicate regarding their use of the shared memory and act in a manner that avoids this pitfall.

## Examples

To destroy a memory segment previously created by SHMMAP with the segment name `myseg`:

SHMUNMAP, 'myseg'

## Syntax

SHMUNMAP, SegmentName

## Arguments

### SegmentName

A scalar string containing the IDL name for the shared memory segment, as assigned by SHMMAP.

## Keywords

None.

## Version History

5.6 | Introduced

## See Also

SHMDEBUG, SHMMAP, SHMVAR