Skip to content

Call xfree on TypedData_Make_Struct selectors#163

Merged
ioquatix merged 1 commit intosocketry:mainfrom
jhawthorn:malloc_xfree
Mar 24, 2026
Merged

Call xfree on TypedData_Make_Struct selectors#163
ioquatix merged 1 commit intosocketry:mainfrom
jhawthorn:malloc_xfree

Conversation

@jhawthorn
Copy link
Copy Markdown
Contributor

TypedData_Make_Struct uses Ruby's xmalloc internally, so the corresponding free functions should call xfree rather than free.

Ruby's xmalloc tracks allocation size internally so the GC knows how much memory is in use. In most release builds this just causes this memory to be missed in accounting (causing extra GCs). However in debug builds in Ruby 4.1dev the mismatched operations may crash.

TypedData_Make_Struct uses Ruby's xmalloc internally, so the
corresponding free functions should call xfree rather than free.

Ruby's xmalloc tracks allocation size internally so the GC knows how
much memory is in use. In most release builds this justs causes this
memory to be missed in accounting (causing extra GCs). However in debug
builds in ruby 4.1dev the mismatched operations may crash.
@ioquatix ioquatix merged commit 235513d into socketry:main Mar 24, 2026
26 of 29 checks passed
@ioquatix
Copy link
Copy Markdown
Member

Thanks, I didn't know it!

@ioquatix ioquatix added this to the v1.14.5 milestone Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants