Trying to send large table in message

Hi all.

So I need to transfer a lua table with 40 tables in it (don’t ask, it’s a prototype :slight_smile:) from one script to another via msg.post, but I get this error:

buffer (9 bytes) too small for table, exceeded at key for element #1

Is there any way to make buffer bigger?

Defold documentation would suggest that the limit on message size is not negotiable. It looks like you need to get creative!

1 Like

to quote the manual

There is a hard limit to the message parameter table size. This limit is set to 2 kilobytes. There is currently no trivial way to figure out the exact memory size a table consumes but you can use collectgarbage(“count”) at before and after inserting the table to monitor memory use.

1 Like

No, as others have pointed out already it is not possible to increase the buffer. I would suggest that you store your large datastructure in a lookup table of some kind inside a Lua module and in your message pass the key instead of the whole table, and on the receiving end you use the key to retrieve the large data structure from the lookup table.

4 Likes

Oh. Ok then :slight_smile:
Thanks for the clarification!

Note that data sent by messaging comes with a cost. More data, higher performance hit.

1 Like

I’m adding a note about this in the api docs as well.

1 Like