Categorygithub.com/Jille/gcmmap
modulepackage
0.0.2
Repository: https://github.com/jille/gcmmap.git
Documentation: pkg.go.dev

# README

gcmmap

Go Reference

Package gcmmap provides mmap(2) that can be garbage collected by Go's garbage collector. There is no explicit munmap.

It works by allocating a []byte from the Go allocator, which we can set a finalizer on, and then using mmap with MAP_FIXED to overwrite it with your requested mmap. When the finalizer runs, we undo that and put a normal anonymous read/write mapping back.

USE AT YOUR OWN RISK.

I still haven't decided whether I dare to use it myself.

# Functions

Mmap calls mmap(2) and uses the garbage collector to unmap when no more references exist.

# Variables

NumActive is the number of mmaps that have not yet been garbage collected.