summaryrefslogtreecommitdiff
path: root/src/memory.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/memory.zig')
-rw-r--r--src/memory.zig18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/memory.zig b/src/memory.zig
index e3fa4ac9..31b04b99 100644
--- a/src/memory.zig
+++ b/src/memory.zig
@@ -53,7 +53,9 @@ pub const limits = struct {
pub const host = 512 * MiB;
pub const tree_sitter = 256 * MiB;
pub const image = 256 * MiB;
- pub const pdf = if (!config.mupdf) 64 * KiB else 512 * MiB;
+ /// What kinds keep past a call (`pa_api.heap`): the pdf addon's
+ /// documents, MuPDF's own memory and the pages' pixels.
+ pub const addon = 512 * MiB;
/// One language query's working memory (its parsed answers, the rows
/// it writes): a hard bound, nothing spills. Callstack walks until it
/// would leave less than its rendering reserve.
@@ -70,7 +72,7 @@ pub const Allocators = struct {
lsp: Allocator,
tree_sitter: Allocator,
image: Allocator,
- pdf: Allocator,
+ addon: Allocator,
};
/// One arena's fixed region on a native target, handed out in runs of 4 KiB
@@ -286,8 +288,8 @@ var tree_sitter_bits: [bitsFor(limits.arena.tree_sitter)]u64 = @splat(0);
var tree_sitter_region: Region = .{ .size = limits.arena.tree_sitter, .bits = &tree_sitter_bits };
var image_bits: [bitsFor(limits.arena.image)]u64 = @splat(0);
var image_region: Region = .{ .size = limits.arena.image, .bits = &image_bits };
-var pdf_bits: [bitsFor(limits.arena.pdf)]u64 = @splat(0);
-var pdf_region: Region = .{ .size = limits.arena.pdf, .bits = &pdf_bits };
+var addon_bits: [bitsFor(limits.arena.addon)]u64 = @splat(0);
+var addon_region: Region = .{ .size = limits.arena.addon, .bits = &addon_bits };
var host_bits: [bitsFor(limits.arena.host)]u64 = @splat(0);
var host_region: Region = .{ .size = limits.arena.host, .bits = &host_bits };
@@ -429,7 +431,7 @@ fn pinned(allocator: Allocator, bytes: []const u8, alignment: std.mem.Alignment)
/// was freed (a V8 Callstack page left 21 MiB free in its heap; this returned
/// 20). Walks every arena and the heap, so for rare, large events only.
pub fn trim() void {
- inline for (.{ &pardes_region, &frame_region, &lsp_region, &tree_sitter_region, &image_region, &pdf_region, &host_region }) |r| r.trim();
+ inline for (.{ &pardes_region, &frame_region, &lsp_region, &tree_sitter_region, &image_region, &addon_region, &host_region }) |r| r.trim();
if (comptime builtin.os.tag != .linux or builtin.abi.isMusl() or !builtin.link_libc) return;
const glibc = struct {
extern "c" fn malloc_trim(pad: usize) c_int;
@@ -472,7 +474,7 @@ pub fn init(fallback: Allocator) Allocators {
.lsp = lsp_region.init(spill),
.tree_sitter = tree_sitter_region.init(spill),
.image = image_region.init(spill),
- .pdf = pdf_region.init(spill),
+ .addon = addon_region.init(spill),
};
}
@@ -481,7 +483,7 @@ pub fn deinit() void {
if (!debug_enabled) return;
var leaked = false;
// The host's arena lives as long as the process (`host`).
- inline for (.{ &pardes_region, &frame_region, &lsp_region, &tree_sitter_region, &image_region, &pdf_region }) |r| leaked = r.deinit() or leaked;
+ inline for (.{ &pardes_region, &frame_region, &lsp_region, &tree_sitter_region, &image_region, &addon_region }) |r| leaked = r.deinit() or leaked;
if (leaked) @panic("allocator leaks detected");
}
@@ -547,7 +549,7 @@ test "memory limits preserve desktop capacities" {
try std.testing.expectEqual(512 * MiB, limits.arena.lsp);
try std.testing.expectEqual(256 * MiB, limits.arena.tree_sitter);
try std.testing.expectEqual(256 * MiB, limits.arena.image);
- try std.testing.expectEqual(if (config.mupdf) 512 * MiB else 64 * KiB, limits.arena.pdf);
+ try std.testing.expectEqual(512 * MiB, limits.arena.addon);
}
test "a pinned blob's free is put off until its last pin goes" {