unmap#

Release a mapping explicitly before the scalar goes out of scope.

Synopsis#

unmap $map;

When to call it#

Most programs never need to. A mapped scalar is unmapped automatically when it is freed — at scope exit for my variables, at the end of the program for globals — and the kernel flushes any pending writes as part of that. Call unmap explicitly when you want to release the memory (and close the mapping of the file) before the natural lifetime of the scalar ends.

After unmap, the scalar becomes an ordinary empty string and can be reused for any purpose, including being mapped again.

Edge cases#

  • Calling unmap on a scalar that is not mapped raises an exception.

Differences from upstream#

Fully compatible with upstream File::Map 0.71.

See also#

  • sync — flush writes without releasing the mapping.