RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

RunMat™ is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

LicensePrivacy
/
See all docs
Builtin Reference
    • loadobj
    • saveobj

saveobj — Return the MAT-file serialization payload for an object.

saveobj(a) returns the payload that save should write for object a. If the object's class registers a saveobj method, RunMat dispatches to that method. Otherwise RunMat returns a scalar struct containing the object's stored public runtime properties.

Syntax

b = saveobj(a)

Inputs

NameTypeRequiredDefaultDescription
aAnyYes—Object to serialize.

Returns

NameTypeDescription
bAnySerialized object representation.

Errors

IdentifierWhenMessage
RunMat:ObjectSerialization:InvalidArgumentThe input is not an object or serialized object envelope.object serialization: invalid argument
RunMat:ObjectSerialization:DispatchA saveobj or loadobj method cannot be resolved or executed.object serialization: method dispatch failed
RunMat:ObjectSerialization:RecursionLimitObject serialization nesting exceeds the supported recursion limit.object serialization: recursion limit exceeded

How saveobj works

  • The public signature is b = saveobj(a).
  • Object and handle-object inputs dispatch to a registered Class.saveobj method when one is available.
  • When no registered overload exists, RunMat serializes the object's stored property map as a scalar struct.
  • Nested objects inside structs or cells are serialized recursively before MAT-file encoding.
  • save automatically applies this object serialization path before writing MAT-file variables.
  • Recursion is bounded and reports RunMat:ObjectSerialization:RecursionLimit for cyclic or excessively nested object graphs.
  • Non-object inputs to direct saveobj, including typed integers and gpuArray values, raise RunMat:ObjectSerialization:InvalidArgument before serialization. Integer-valued properties nested inside an object remain opaque payloads and preserve authoritative native storage.

Does RunMat run saveobj on the GPU?

saveobj does not launch provider kernels.

save remains the residency sink for any GPU values that appear inside the serialized payload.

GPU memory and residency

saveobj itself is host-side object metadata work. If a serialized payload contains GPU-resident numeric properties, save gathers those values when it converts the payload to MAT-file arrays.

Examples

Return a default property payload

obj = new_object('Point');
payload = saveobj(obj)

Save an object through MAT-file serialization

obj = new_object('Point');
save('object_state.mat', 'obj')

Using saveobj with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how saveobj changes the result.

Run a small saveobj example, explain the result, then change one input and compare the output.

FAQ

Does save call saveobj automatically?⌄

Yes. Before MAT-file encoding, RunMat walks selected values and applies registered saveobj methods for object and handle-object values.

What is saved when no class-specific method exists?⌄

RunMat writes the current runtime property map in an internal object envelope so load can reconstruct an object with the same class name and stored properties.

Are handle identities preserved?⌄

No. Current support serializes the referenced object's properties. It does not preserve handle identity, listener state, or aliasing relationships across save/load.

Related Oop functions

Serialization

loadobj

Indexing

numArgumentsFromSubscript · subsasgn · subsref

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how saveobj is executed, line by line, in Rust.

  • View the source for saveobj in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • How saveobj works
  • Does RunMat run saveobj on the GPU?
  • GPU memory and residency
  • Examples
  • Return a default property payload
  • Save an object through MAT-file serialization
  • Using saveobj with coding agents
  • FAQ
  • Related Oop functions
  • Serialization
  • Indexing
  • Open-source implementation
  • About RunMat