Repository navigation
docs(arrow/memory): document allocator alignment and which allocator to use when C retains buffers - #1302
Merged
zeroshade merged 1 commit intoSep 8, 2026
Conversation
…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
approved these changes
Sep 8, 2026
Member
|
Thanks for this! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
Nothing in the
memorypackage said what alignment an allocator guarantees, or which allocator touse for buffers that C will keep after the cgo call. The
cdataexport comment named only theCgoArrowAllocator, which needs the Arrow C++ library, whilemallocatorcovers the same needwithout it. Discussed in #1297.
What changes are included in this PR?
Two sections in the
memorypackage comment: the 64-byte alignmentGoAllocatorandmallocator.NewMallocatorprovide andNewMallocatorWithAlignmentfor anything larger; and thecgo pointer rule with the two allocators that return C memory. Doc comments on
GoAllocatorandNewGoAllocator. TheExportArrowRecordBatchcomment now namesmallocator.MallocatoralongsideCgoArrowAllocatorand points at the package doc.Are these changes tested?
Documentation only;
go vetandgo build ./...pass andgo doc ./arrow/memoryrenders the new sections.Are there any user-facing changes?
Documentation only.
Closes #1297.