Stream: beginners

Topic: understanding RocListWith(u8, false)


view this post on Zulip removewingman (Oct 19 2026 at 12:57):

I have the following host function file_content_bytes_absolute! : Str => Try(List(U8), [FileReadErr(Str)])
which returns an List(U8), in Zig this is RocListWith(u8, false), the false means non-refcounted primitives, afaik.

If I return a list with something, I get an memory error tho.

error(SafeAllocator): leaked [addr: 7f14f6596010, len: 24 (0x18) align: 8] allocated at:
/home/rw/media/repos/roc/restricted/src/roc_platform_abi.zig:468:60: 0x3e4728 in allocate (host.zig)
            const base: [*]u8 = @ptrCast(roc_host.roc_alloc(roc_host, total, alloc_align));
                                                           ^
/home/rw/media/repos/roc/restricted/src/roc_platform_abi.zig:486:34: 0x3e3f66 in fromSlice (host.zig)
            const list = allocate(slice.len, roc_host);
                                 ^
/home/rw/media/repos/roc/restricted/src/file.zig:56:79: 0x3e3c15 in hostedContentBytesAbsolute (host.zig)
    return .{ .tag = .Ok, .payload = .{ .ok = RocListWith(u8, false).fromSlice("whatever", roc_host) } };
                                                                              ^
???:?:?: 0x7d14f5a04766 in ??? (???)

error: Memory leak detected! Times: 1

(roc test/file.roc)

I understand that the list has one ref left and someone needs to call .decref after the roc program finished, but where do I need to add that or how to configure the platform that this is recognized?

The File https://codeberg.org/removewingman/restricted-roc/src/commit/a33e8f512faa7a6f5c32149702f56d3083cdad98/src/file.zig#L56

running latest roc and zig

view this post on Zulip Anton (Oct 19 2026 at 17:45):

Hi @removewingman,
Is latest Roc nightly-2026-10-18-1df370f and latest zig zig-0.18.0-dev.349+d924f83b?
I will start investigating once I have the versions confirmed.


Last updated: Nov 04 2026 at 18:54 UTC