NATTools / stunlib

STUN and TURN library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Memory usage of struct STUN_CLIENT_DATA

SStorm opened this issue · comments

Hey there, in the current implementation the STUN_CLIENT_DATA struct is more than 130k, having statically allocated a whole bunch of things. This makes it fairly hard to use in embedded scenarios, where that much isn't available. The main culprit is STUN_TRANSACTION_DATA of which there is 60 x 2200b allocated. I'm planning on working to shrink down this memory usage, firstly by being able to define your own MAX_STUN_TRANSACTIONS, however would like to take it down to something sub-5k. Any tips/ideas how you would go about doing so? There's a bunch of statically allocated strings (i.e. stun username) that could be smaller if they aren't needed (i.e. using a public STUN server).

Also, please consider my other PR! :)

Tricky that is.. The library is close to 12 years old now and was designed to run on systems we knew the amount of memory and how many simultaneous calls they was supposed to handle. So static allocation was safer than dynamic allocation and dealing with out of memory scenarios.

But limiting number of supported transactions is a good start. And as you say maybe move some of the les used variables to use the heap?

We had plans to start moving this to C++, but its hard to get time to change a working library.