You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the usage question you have. Please include as many useful details as possible.
Perhaps my limited C knowledge is making me miss something obvious, but I think the producer examples on this page of the documentation leak memory? Child schemas are malloced:
//// Initialize child type #0//child=schema->children[0] =malloc(sizeof(structArrowSchema));
Then in the release implementation, we free the array of child pointers and call release on the children array, but don't actually free the child ArrowSchema allocations:
staticvoidrelease_malloced_type(structArrowSchema*schema) {
inti;
for (i=0; i<schema->n_children; ++i) {
structArrowSchema*child=schema->children[i];
if (child->release!=NULL) {
child->release(child);
}
}
free(schema->children);
// Mark releasedschema->release=NULL;
}
Since (as far as I can tell?) the docs don't otherwise explicitly state what the lifetime of these children is, it could be nice to fix this? Reading the C++ ExportArray implementation, it seems like these are in fact freed in the release call via the private_data pointer in at least the C++ implementation.
Component(s)
C, Documentation
The text was updated successfully, but these errors were encountered:
That said, it looks like you're right. There should be a free(child); after child->release(child); Would you be willing to contribute a PR to fix it? 😄
### Rationale for this change
Fix memory leak in C export examples. Fixes#36050.
### What changes are included in this PR?
Change to example in docs
### Are these changes tested?
Docs only change.
### Are there any user-facing changes?
No
* Closes: #36050
Authored-by: lord <lord@users.noreply.github.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
Describe the usage question you have. Please include as many useful details as possible.
Perhaps my limited C knowledge is making me miss something obvious, but I think the producer examples on this page of the documentation leak memory? Child schemas are malloced:
Then in the release implementation, we free the array of child pointers and call release on the children array, but don't actually free the child ArrowSchema allocations:
Since (as far as I can tell?) the docs don't otherwise explicitly state what the lifetime of these children is, it could be nice to fix this? Reading the C++ ExportArray implementation, it seems like these are in fact freed in the release call via the private_data pointer in at least the C++ implementation.
Component(s)
C, Documentation
The text was updated successfully, but these errors were encountered: