Implementation:Google deepmind Mujoco mj deleteData mj deleteModel
Appearance
| 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