I'm reading this article on web workers and I came across this section on Transferable Objects:
With Transferable Objects, data is transferred from one context to another. It is zero-copy, which vastly improves the performance of sending data to a Worker. Think of it as pass-by-reference if you're from the C/C++ world. However, unlike pass-by-reference, the 'version' from the calling context is no longer available once transferred to the new context.
Why? Based on my understanding of Abstract Stack Machines, it seems perfectly reasonable that original pointer can be left in tact. Admittedly, since the data is now referenced from another context, it would be a tricky task to continue working with it, but not totally unreasonable. Why is the original object cleared?
I'd also like to learn how this whole process takes place under the hood, if anyone has some valuable insight there.
One possible reason to transfer an object would be to reduce the amount of memory used for storing multiple copies of the same object.
It is up to the definition of individual platform objects to determine what data is transferred by these steps. Typically the steps are very symmetric.
See also 2.9.2. Transferable objects