gcmmap

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2024 License: BSD-2-Clause Imports: 6 Imported by: 0

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.

Documentation

Overview

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

It uses unsafe and evil trickery. USE AT YOUR OWN RISK.

Index

Constants

This section is empty.

Variables

View Source
var NumActive atomic.Int32

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

Functions

func Mmap

func Mmap(fd int, offset int64, len, prot, flags int) ([]byte, error)

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

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL