question

Upvotes
Accepted
791 11 16 20

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 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Upvotes
Accepted
322 11 16 21

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 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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