vtprotobuf icon indicating copy to clipboard operation
vtprotobuf copied to clipboard

Pooled Objects - Recursive Pool Usage

Open steve-gray opened this issue 6 months ago • 1 comments

When unmarshalling an object from a pooled instance, the pooling support should be able to use pooled instances all the way down as it grabs and allocates objects. For example if:

message SomeMessage {
    SecondMessage header = 1;
    repeated OtherMessage items = 2;
}

Even if I pool the outer object, only that level is being serviced from the pool. As it expands the children, these are always new allocations today.

When unmarshalling into a pooled instance, I feel there should be a code path that obtains all instances down the tree (regardless of object depth) from the pools. An additional helper method that returns all instances to the pool would likewise be be valuable. This would enable complex structures to make use of pooling.

steve-gray avatar Jun 22 '25 01:06 steve-gray

Agree that this would be very useful - to help control the GC impact on complex Messages.

ncorran avatar Jul 26 '25 12:07 ncorran