Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Google deepmind Mujoco mj deleteData mj deleteModel

From Leeroopedia
Knowledge Sources
Domains Memory_Management, Physics_Simulation
Last Updated 2026-02-15 06:00 GMT

Overview

Concrete tools for deallocating MuJoCo simulation data and model structures provided by the MuJoCo C API.

Description

mj_deleteData frees all memory associated with an mjData structure (arena, plugin instances, data buffer). mj_deleteModel frees all memory associated with an mjModel structure. Both functions safely handle NULL pointers.

Usage

Call mj_deleteData first, then mj_deleteModel when shutting down a simulation. These must be called for every corresponding allocation to avoid memory leaks.

Code Reference

Source Location

  • Repository: mujoco
  • File: src/engine/engine_io.c
  • Lines (mj_deleteData): 1571-1576
  • Lines (mj_deleteModel): 666-671

Signature

void mj_deleteData(mjData* d);
void mj_deleteModel(mjModel* m);

Import

#include <mujoco/mujoco.h>

I/O Contract

Inputs

Name Type Required Description
d mjData* No Simulation data to free (NULL safe)
m mjModel* No Model to free (NULL safe)

Outputs

Name Type Description
(none) void All associated memory is freed

Usage Examples

#include <mujoco/mujoco.h>

mjModel* m = mj_loadXML("model.xml", NULL, error, 1000);
mjData* d = mj_makeData(m);

// ... simulation ...

// Cleanup in reverse order of allocation
mj_deleteData(d);
mj_deleteModel(m);

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment