Skip to content

docs(arrow/memory): document allocator alignment and which allocator to use when C retains buffers - #1302

Merged
zeroshade merged 1 commit into
apache:mainfrom
singhpratech:docs-memory-allocator-alignment
Sep 8, 2026
Merged

zeroshade merged 1 commit into
apache:mainfrom
singhpratech:docs-memory-allocator-alignment

Conversation

@singhpratech

Copy link
Copy Markdown
Contributor

Rationale for this change

Nothing in the memory package said what alignment an allocator guarantees, or which allocator to
use for buffers that C will keep after the cgo call. The cdata export comment named only the
CgoArrowAllocator, which needs the Arrow C++ library, while mallocator covers the same need
without it. Discussed in #1297.

What changes are included in this PR?

Two sections in the memory package comment: the 64-byte alignment GoAllocator and
mallocator.NewMallocator provide and NewMallocatorWithAlignment for anything larger; and the
cgo pointer rule with the two allocators that return C memory. Doc comments on GoAllocator and
NewGoAllocator. The ExportArrowRecordBatch comment now names mallocator.Mallocator alongside
CgoArrowAllocator and points at the package doc.

Are these changes tested?

Documentation only; go vet and go build ./... pass and go doc ./arrow/memory renders the new sections.

Are there any user-facing changes?

Documentation only.

Closes #1297.

…to use when C retains buffers

GoAllocator and mallocator.NewMallocator return 64-byte aligned buffers and
nothing promises more; NewMallocatorWithAlignment is the route to a larger
alignment. Go-heap buffers must not be retained by C past the cgo call;
mallocator is the C-memory allocator that needs no C++ library, alongside
the CgoArrowAllocator behind the ccalloc tag. The cdata export comment named
only the ccalloc allocator; it now names both.

Closes apache#1297
@zeroshade

Copy link
Copy Markdown
Member

Thanks for this!

@zeroshade
zeroshade merged commit 281776d into apache:main Sep 8, 2026
54 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants