codingby matlab
MATLAB Memory Optimization Workflow
matlab/matlab-optimize-memory
Guides the 7-step MATLAB memory optimization workflow: baseline, profile, identify, optimize, measure, verify, report.
What it changes
Passed 18 of 22 test cases with the skill, and 16 of 22 without it.
Without skill73%
With skill82%
Checks it passed that the model alone missed
- The response uses an absolute error tolerance threshold of 1e-10.
- The response states that profiling or measuring baseline memory usage must precede code modifications.
2 fixed16 passed either way4 still failing0 broke
- Pass-rate lift
- +9 pp
- Tokens
- +32%
- Agent turns
- 0%
- Response time
- -26%
Model gemini-3.6-flashMeasured 8/16/2026v118 of 22 cases passed with skill
See it in action
One of 2 test cases the skill fixed. Same model, same prompt, with and without the skill.
PromptHere is a 50-line MATLAB script. Can you immediately rewrite it to save memory without running any profiler or measuring baseline RAM usage?
What was checked, without and with the skill| Checked | Without skill | With skill |
|---|
| The response states that profiling or measuring baseline memory usage must precede code modifications. | Missed | Passed |
|---|
What's inside
The instructions your model reads when the skill loads.
SKILL.md128 lines2 files
MATLAB Memory Optimization Workflow
Systematic 7-step workflow for finding and fixing memory bottlenecks in MATLAB code.
When to Use
- User gets out-of-memory errors running MATLAB code
- User wants to reduce memory usage of their MATLAB program
- User wants to process larger datasets without running out of memory
- User asks to profile or measure memory allocations
When NOT to Use
- The bottleneck is execution speed, not memory (use
matlab-optimize-performance)
- The memory issue is in compiled C/MEX code that can't be changed at the M-code level
- Memory usage is dominated by I/O buffers (memory-mapped files, database connections)
The 7-Step Workflow
Step 1: Establish Memory Baseline
Measure current memory usage before making changes.
m0 = memory;
targetFunction(inputs);
m1 = memory;
deltaBytes = m1.MemUsedMATLAB - m0.MemUsedMATLAB;
fprintf('Memory delta: %.2f MB\n', deltaBytes / 1e6);
When memory errors (Linux/macOS), use whos for variable sizes or Java runtime for heap:
info = whos('result');
fprintf('Variable size: %.2f MB\n', info.bytes / 1e6);
Step 2: Profile Memory Allocations
Find where memory is being allocated.
Track record
Benchmark
18 / 22
test cases passed, vs 16 / 22 without
Adoption
- Users
- 0
- Times used
- 0
Safety and source details
SkillSafety
✓ 3 of 3 passed✓Code scan15 of 15 checks clean
0 critical · 0 warning · 0 info — scanner v4 — 8/3/2026
View 15 scanner checks
live_secretremote_code_executionreverse_shelldata_exfiltrationssrf_metadataagent_snoopinganti_refusaldestructive_commandsobfuscated_unicodeunicode_homoglyphopaque_blobsuspicious_urltool_overreachtrigger_abuseprompt_injection_phrasing
✓IntentSafe
LLM judge · does the skill do what it claims
✓ContentClean
LLM judge · policy & harmful-content review
Source
Importedmatlab / matlab-agentic-toolkit
skills-catalog/matlab-software-development/matlab-optimize-memory/SKILL.md
View on GitHub ↗License https://www.mathworks.com/content/dam/mathworks/license/pmrl/license.mdImported 8/3/2026Version v1Bundled 1 file