Skip to content

[DOC] Update documentation of ObjectSpace.memsize_of #13986

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 23, 2025

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Jul 23, 2025

RVALUE no longer exists and objects can now have various sizes due to VWA. So I think this API's doc should be updated.

* From Ruby 2.2, memsize_of(obj) returns a memory size that includes
* the slot size occupied by the object. Prior to Ruby 3.2, this was a
* fixed size (sizeof(RVALUE)). From Ruby 3.2 with Variable Width
* Allocation, this is the actual slot size used (1×, 2×, 4×, 8×, or
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got this information from rb_gc_impl_objspace_init: https://github.com/Shopify/ruby/blob/9eac1c3a888088912fcc1cbb6fc677fd1ad5683c/gc/default/default.c#L9331-L9337

Let me know if it's correct?

@st0012 st0012 force-pushed the doc-update-rvalue-references branch from 9eac1c3 to 460ab65 Compare July 23, 2025 12:12
@st0012
Copy link
Member Author

st0012 commented Jul 23, 2025

@peterzhu2118 So does it make sense to just drop everything after This method is only expected to work with CRuby.?

@peterzhu2118
Copy link
Member

No, I think there's still value in making it clear that it returns the size of the slot + externally allocated memory.

@st0012 st0012 force-pushed the doc-update-rvalue-references branch from 460ab65 to eab89a7 Compare July 23, 2025 15:03
@st0012 st0012 requested a review from peterzhu2118 July 23, 2025 15:03
@peterzhu2118 peterzhu2118 merged commit 78820e8 into ruby:master Jul 23, 2025
45 checks passed
@peterzhu2118 peterzhu2118 deleted the doc-update-rvalue-references branch July 23, 2025 19:49
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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy