question

Upvotes
Accepted
791 9 7 14

Predicting Required Buffer Size

I am sending fix messages encoded into RWF using UPA Java. These messages have a wide range of different sizes. I would like to allocate Buffers for encoding that are close to what is actually needed, rather than always allocating a buffer that is large enough for the “worst case.”

While some of our values are coverted to numbers, most of FIX is UTF-8. Is there a ratio of bytes in RWF for Bytes in a java.lang.String that I can use to “guess” what I will need?

elektronelektron-sdkrrteta-apielektron-transport-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

1 Answer

Upvotes
Accepted
322 5 12 16

If you know your payload data length, you can just add a fixed RWF overhead number to your length when requesting the buffer size. I’ve used 128 bytes for this in the past.

However, this number may be too small if you’re using extended headers, large message keys, or permission expressions in the messages you’re sending. You may need to tweak for your specific usage.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea