v1.0.0
Release Notes: v1.0.0
malloc v1.0.0 marks the first stable release version. The package now supports concurrent access, dynamic memory growth, and memory-mapped allocation.
Breaking Changes
Function signatures changed:
// Old (v0.10.0)
func NewArena(size uint64) *Arena
func NewArenaAt[T any](buf []T) *Arena
// New (v1.0.0)
func NewArena(size uint64, opts ...Opt) *Arena
func NewArenaAt[T any](buf []T, opts ...Opt) *ArenaExisting code continues to work without changes. The new optional parameters add configuration without breaking compatibility.
New Features
Thread-Safe Arenas
Arenas now protect concurrent access with a mutex. Multiple goroutines can allocate and free memory simultaneously.
arena := malloc.NewArena(64 * 1024)
// Safe to call from multiple goroutines
go func() {
p, _ := malloc.Malloc[int](arena)
malloc.Free(arena, p)
}()Dynamic Growth
Arenas grow automatically when they run out of space. The backend determines how growth occurs.
// Starts small, grows as needed
arena := malloc.NewArena(1024, malloc.Backend(malloc.SliceBackend))Memory-Mapped Allocation
The MmapBackend allocates memory through mmap(2) on Unix or VirtualAlloc on Windows. This keeps allocated memory outside the Go heap.
// Allocate 4KB via mmap
arena := malloc.NewArena(4096, malloc.Backend(malloc.MmapBackend(0, 0)))Platforms: Linux, macOS, Windows
Improvements
- Improved error detection for double-free bugs
- Added GitHub Actions CI across Go 1.25, 1.26 and all supported platforms
Known Limitations
- The mmap backend does not support BSD systems (except Darwin)
- Growth performance depends on the backend implementation
- Minimum allocation size remains 16 bytes
Migration Guide
From v0.10.0
No code changes required. The API remains compatible.
To opt into new features:
// Enable growth
arena := malloc.NewArena(1024, malloc.Backend(malloc.SliceBackend))
// Use mmap
arena := malloc.NewArena(4096, malloc.Backend(malloc.MmapBackend(0, 0)))Requirements
- Go 1.25 or later
- For mmap support: Linux, macOS, or Windows