Marshalling (computer science)

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Magioladitis (talk | contribs) at 00:08, 5 April 2014 (clean up using AWB (10072)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computer science, marshalling or marshaling is the process of transforming the memory representation of an object to a data format suitable for storage or transmission, and it is typically used when data must be moved between different parts of a computer program or from one program to another. Marshalling is similar to serialization and is used to communicate to remote objects with an object, in this case a serialized object. It simplifies complex communication, using custom/complex objects to communicate instead of primitives. The opposite, or reverse, of marshalling is called unmarshalling (or demarshalling, similar to deserialization).

Usage

Marshalling is used within implementations of different remote procedure call (RPC) mechanisms, where it is necessary for transporting data between processes and/or between threads. In Microsoft's Component Object Model (COM), interface pointers must be marshalled when crossing COM apartment boundaries[1] (that is, crossing between instances of the COM library).[2] In the .NET Framework, the conversion between an unmanaged type and a CLR type, as in the P/Invoke process, is also an example of an action that requires marshalling to take place.[3]

Additionally, marshalling is used extensively within scripts and applications that utilize the XPCOM technologies provided within the Mozilla Application Framework. The Mozilla Firefox browser is a popular application built with this framework that additionally allows scripting languages to use XPCOM through XPConnect (Cross-Platform Connect).

Comparison with serialization

The term "marshal" is considered to be synonymous with "serialize" in the Python standard library,[4] but the terms are not synonymous in the Java-related RFC 2713:[note 1]

To "marshal" an object means to record its state and codebase(s) in such a way that when the marshalled object is "unmarshalled", a copy of the original object is obtained, possibly by automatically loading the class definitions of the object. You can marshal any object that is serializable or remote. Marshalling is like serialization, except marshalling also records codebases. Marshalling is different from serialization in that marshalling treats remote objects specially. (RFC 2713)

To "serialize" an object means to convert its state into a byte stream in such a way that the byte stream can be converted back into a copy of the object.

See also

Notes

  1. ^ "Codebase" here is used in its Java-specific meaning, to refer to a list of URLs where the object code can be loaded from, rather than in the more general meaning of codebase which refers to source code.

References

  1. ^ Apartments and COM Threading Models
  2. ^ "CoInitializeEx function (COM)". Windows Desktop App Development. Retrieved 2013-02-22.
  3. ^ Interop Marshaling Overview
  4. ^ Marshal Python module