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
In the binary writers (v1.0 and v1.1), length-prefixed container writers bump-allocate a fresh encoding buffer where they can encode their child values to calculate their aggregated byte length. When encoding is done, the length is encoded into a parent buffer followed by the encoding buffer's contents. After this point, the encoding buffer becomes inaccessible, and the memory it occupies remains unavailable until the bump allocator is eventually reset during a flush().
Instead, we should maintain a stack of these encoding buffers that we can pop from and push to over the course of encoding, minimizing the amount of memory that is temporarily "leaked" between calls to flush(). This will require plumbing an (e.g.) EncodingResources reference through the ValueWriter implementations so buffers can be acquired and released at any level of encoding depth.
In the binary writers (v1.0 and v1.1), length-prefixed container writers bump-allocate a fresh encoding buffer where they can encode their child values to calculate their aggregated byte length. When encoding is done, the length is encoded into a parent buffer followed by the encoding buffer's contents. After this point, the encoding buffer becomes inaccessible, and the memory it occupies remains unavailable until the bump allocator is eventually reset during a
flush()
.Instead, we should maintain a stack of these encoding buffers that we can pop from and push to over the course of encoding, minimizing the amount of memory that is temporarily "leaked" between calls to
flush()
. This will require plumbing an (e.g.)EncodingResources
reference through theValueWriter
implementations so buffers can be acquired and released at any level of encoding depth.cc @popematt
The text was updated successfully, but these errors were encountered: