Better memory setting and reporting, updated example models.

- Memory heuristic rounds up to the nearest MB.
- `simulate` reports total memory currently allocated in the info box.
- All example models use `<size memory/>` rather than legacy attributes.
- Regenerated `example_saved.xml` and reformatted original model in [overview chapter](https://mujoco.readthedocs.io/en/latest/overview.html?#examples).
- `<size>` top-level section does not get written if empty.

PiperOrigin-RevId: 486702670
Change-Id: I0306e335f32344c59562ba606664ec9d2101f8a8
This commit is contained in:
Yuval Tassa
2022-11-07 10:35:50 -08:00
committed by Copybara-Service
parent 9370039015
commit 5004a4c8c5
18 changed files with 107 additions and 101 deletions
+6
View File
@@ -2689,6 +2689,12 @@ void mjCModel::TryCompile(mjModel*& m, mjData*& d, const mjVFS* vfs) {
njmax * m->nv * (2 * sizeof(int) + 2 * sizeof(mjtNum)) +
njmax * njmax * (sizeof(int) + sizeof(mjtNum)));
m->nstack += (arena_bytes / sizeof(mjtNum)) + (arena_bytes % sizeof(mjtNum) ? 1 : 0);
// round up to the nearest megabyte
constexpr int kMegabyte = (1 << 20) / sizeof(mjtNum); // number of mjtNum's in 1 Mb
int nstack_mb = m->nstack / kMegabyte;
int residual_mb = m->nstack % kMegabyte ? 1 : 0;
m->nstack = kMegabyte * (nstack_mb + residual_mb);
}
// create data