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
require 'google/protobuf'
Google::Protobuf::DescriptorPool.generated_pool.build do
add_message "hi" do
# vary this to see more or less allocations
10.times do |i|
optional :"resource_name_#{i}", :string, i+1
end
end
end
module Mod
Hi = Google::Protobuf::DescriptorPool.generated_pool.lookup("hi").msgclass
end
h = Mod::Hi.new
data = Mod::Hi.encode(h)
# 4 GCs to force all allocated objects to either be removed
# or moved to the oldest generation
GC.start
GC.start
GC.start
GC.start
start_alloc = GC.stat
# uncomment either
#Mod::Hi.decode("")
#Mod::Hi.decode(data)
end_alloc = GC.stat
p end_alloc[:total_allocated_objects]-start_alloc[:total_allocated_objects]
The text was updated successfully, but these errors were encountered:
(Just dropped this in here from a hangout with @haberman)
fables-tales
changed the title
Ruby: decoding an empty protocol buffer allocates objects for every field in that . descriptor
Ruby: decoding an empty protocol buffer allocates objects for every field in that protobuf's descriptor
Aug 12, 2019
The text was updated successfully, but these errors were encountered: