Are tables sent as a memory reference?

Hi! I was taking a shower when a question I’ve wondered about for many years crossed my mind yet again. I have a background in some C++ coding and know that variables in most traditional C compilers are just references to memory locations on the OS.

I was wondering if: when a remoteEvent/Function is fired, if you send a table as an argument, is that table just an alphanumeric variable, or does the entire table and all of it’s content get sent as well? Obviously this would make a huge difference since sending #gki758hfe to the server is a LOT less data intensive then sending 5 instances and all their properties.

Thanks!

Nope this is not the case. You can test this yourself. Try sending the same table twice and printing the output. You’ll get two different table ids. The table id is actually just a memory address where the table contents are stored. So that means the content of the table is getting sent and a new table is being created.

3 Likes

Thaaaank you very much!

This was unfortunately my assumption. Thankfully I don’t have to change any existing code because of this assumption, but still, kinda sucks haha

1 Like

Just to add on: this happens with (practically) every value sent through a remote. They don’t pass by reference, they create a copy of the data sent and transfer that over. Don’t quote me, I saw this somewhere and the tests I did happened to show that as well.

Basically applies to anything not shared by server and client, because it would be dummy expensive to query the client every time you want to read/write from a table reference passed to the server.

Instances are sent as IDs that are checked on the receiving machine, from my knowledge.

4 Likes