Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Google deepmind Mujoco mjv freeScene mjr freeContext

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

Overview

Concrete tools for freeing visualization scene and GPU rendering context resources provided by the MuJoCo API.

Description

mjv_freeScene frees all CPU-side scene buffers (geom arrays, flex data, skin data) and resets the scene struct to defaults. mjr_freeContext frees all GPU resources (OpenGL textures, shaders, framebuffer objects, font bitmaps) and resets the context struct.

Usage

Call before application shutdown. Free scene before context. The OpenGL context must still be active when calling mjr_freeContext.

Code Reference

Source Location

  • Repository: mujoco
  • File (mjv_freeScene): src/engine/engine_vis_init.c
  • Lines: 280-305
  • File (mjr_freeContext): src/render/render_context.c
  • Lines: 1813-1870

Signature

void mjv_freeScene(mjvScene* scn);
void mjr_freeContext(mjrContext* con);

Import

#include <mujoco/mujoco.h>

I/O Contract

Inputs

Name Type Required Description
scn mjvScene* Yes Scene to free
con mjrContext* Yes Context to free (requires active OpenGL)

Outputs

Name Type Description
(none) void All buffers/GPU resources freed, structs zeroed

Usage Examples

// Application shutdown
mjv_freeScene(&scn);
mjr_freeContext(&con);
mj_deleteData(d);
mj_deleteModel(m);
glfwTerminate();

Related Pages

Implements Principle

Page Connections

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