Skip to content

Allocator.free(arg)

Chung Leong edited this page Aug 4, 2026 · 3 revisions

JavaScript | PHP


Free previous allocated memory.

Usage

const std = @import("std");

var gpa = std.heap.DebugAllocator(.{}).init;
pub const allocator = gpa.allocator();
pub const Point = struct {
    x: i32,
    y: i32,
};
import { allocator, Point } from './allocator-js-example-2.zig';

const dv = allocator.alloc(4);
allocator.free(dv);
const point = new Point({ x: 1, y: 2 }, { allocator });
allocator.free(point);

Arguments:

  • arg
    A DataView returned by alloc() or a Zig object created using the allocator.

Return value:

undefined

Clone this wiki locally