Skip to content

Ruby: extension types should define a proper memsize function #10280

@casperisfine

Description

@casperisfine

Here's an snippet from a Ruby heap dump (generated with ObjectSpace.dump_all

{"address":"0x7fa2dadd7320", "type":"DATA", "class":"0x7fa3eb7ab408", "struct":"Google::Protobuf::Internal::Arena", "memsize":40}
{"address":"0x7fa2dadd1678", "type":"DATA", "class":"0x7fa3eb7ab408", "struct":"Google::Protobuf::Internal::Arena", "memsize":40}
{"address":"0x7fa2dadd3c70", "type":"DATA", "class":"0x7fa3eb7ab408", "struct":"Google::Protobuf::Internal::Arena", "memsize":40}
{"address":"0x7fa2dadcfaa8", "type":"DATA", "class":"0x7fa3eb7ab408", "struct":"Google::Protobuf::Internal::Arena", "memsize":40}
{"address":"0x7fa2dadc9c98", "type":"DATA", "class":"0x7fa3eb7ab408", "struct":"Google::Protobuf::Internal::Arena", "memsize":40}
{"address":"0x7fa2dadcb390", "type":"DATA", "class":"0x7fa3eb7ab408", "struct":"Google::Protobuf::Internal::Arena", "memsize":40}

As you can see, all these Google::Protobuf::Internal::Arena instances claim to be 40 bytes, which is obviously a lie.

This is because the memsize function is not defined:

{Arena_mark, Arena_free, NULL},

What language does this apply to?

Ruby

Describe the problem you are trying to solve.

I'd like to have a semi-accurate idea of how much memory the google-protobuf gem is holding onto.

Describe the solution you'd like

I'd like these functions to be defined (Arena, Message, etc). They don't have to be 100% accurate, not particularly fast. It's a debugging facility.

Describe alternatives you've considered

I don't see any.

cc @zhangskz because #9384 (comment)

Metadata

Metadata

Labels

enhancementinactiveDenotes the issue/PR has not seen activity in the last 90 days.ruby

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions