[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75MGKW2WSGG2C03FBMTNPR1":3,"skill-same:01M75MGKW2WSGG2C03FBMTNPR1":66},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":29,"commitSha":30,"skillDirectory":31,"forksCount":32,"repositoryHtmlUrl":33,"repositoryHomepageUrl":6,"ownerHtmlUrl":34,"ownerBlogUrl":35,"ownerDescription":6,"updatedAt":36,"install":37,"resources":50},"01M75MGKW2WSGG2C03FBMTNPR1","matlab-optimize-memory",null,"Guides the 7-step MATLAB memory optimization workflow: baseline, profile, identify, optimize, measure, verify, report. Use when asked to reduce MATLAB memory usage, find memory bottlenecks, fix out-of-memory errors, or optimize memory-intensive code.","stanfish06\u002Fskillquarium","stanfish06","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F93099613?v=4","01M75F1CK4ZW109ZK3T26VN52F","Zhiyuan","01M75F1CM53VH6F79DZ8GXKKES",12,"BSD-2-Clause","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fmatlab-optimize-memory\u002FLICENSE.md","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fmatlab-optimize-memory\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: matlab-optimize-memory\ndescription: \"Guides the 7-step MATLAB memory optimization workflow: baseline, profile, identify, optimize, measure, verify, report. Use when asked to reduce MATLAB memory usage, find memory bottlenecks, fix out-of-memory errors, or optimize memory-intensive code.\"\nlicense: MathWorks BSD-3-Clause\nmetadata:\n  author: MathWorks\n  version: \"1.1\"\n---\n\n# MATLAB Memory Optimization Workflow\n\nSystematic 7-step workflow for finding and fixing memory bottlenecks in MATLAB code.\n\n## When to Use\n\n- User gets out-of-memory errors running MATLAB code\n- User wants to reduce memory usage of their MATLAB program\n- User wants to process larger datasets without running out of memory\n- User asks to profile or measure memory allocations\n\n## When NOT to Use\n\n- The bottleneck is execution speed, not memory (use `matlab-optimize-performance`)\n- The memory issue is in compiled C\u002FMEX code that can't be changed at the M-code level\n- Memory usage is dominated by I\u002FO buffers (memory-mapped files, database connections)\n\n## The 7-Step Workflow\n\n### Step 1: Establish Memory Baseline\n\nMeasure current memory usage before making changes.\n\n```matlab\nm0 = memory;\ntargetFunction(inputs);\nm1 = memory;\ndeltaBytes = m1.MemUsedMATLAB - m0.MemUsedMATLAB;\nfprintf('Memory delta: %.2f MB\\n', deltaBytes \u002F 1e6);\n```\n\nWhen `memory` errors (Linux\u002FmacOS), use `whos` for variable sizes or Java runtime for heap:\n```matlab\ninfo = whos('result');\nfprintf('Variable size: %.2f MB\\n', info.bytes \u002F 1e6);\n```\n\n### Step 2: Profile Memory Allocations\n\nFind where memory is being allocated.\n\n```matlab\nprofile('-memory', 'on');\nfor iter = 1:5\n    targetFunction(inputs);\nend\nprofile off;\np = profile('info');\nft = p.FunctionTable;\n[~, idx] = sort([ft.TotalMemAllocated], 'descend');\nfor i = 1:min(15, numel(idx))\n    f = ft(idx(i));\n    fprintf('%-40s %10.2f MB\\n', f.FunctionName, f.TotalMemAllocated\u002F1e6);\nend\n```\n\nIf `TotalMemAllocated` fields are zero, fall back to `whos` snapshots before\u002Fafter each function call.\n\n**Key things to look for:**\n- Functions with high \"Allocated\" but low \"Freed\" — memory is retained\n- Functions called many times with moderate allocations — total adds up\n- Large gaps between Allocated and Freed — temporaries accumulating\n\n### Step 3: Identify Optimization Opportunities\n\nBased on profiling, identify which patterns apply. See `references\u002Fmemory-patterns.md` for code examples.\n\n| Pattern | Typical Reduction | Look For |\n|---------|-------------------|----------|\n| Cell collection + `vertcat` | O(N²) → O(N) | `[arr; newRow]` inside loops |\n| Implicit expansion over `repmat` | Eliminates full copy | `repmat(A, [1 1 K])` for broadcasting |\n| Clear variables when done | Immediate reclamation | Large arrays used only in early steps |\n| Break chained expressions | 1 fewer peak temporary | `a.*b.*c.\u002Fd` all alive at once |\n| Reuse variables (overwrite in-place) | Avoids output allocation | Separate variables for each step |\n| `max`\u002F`min` instead of masking | Eliminates logical temporary | `x .* (x > 0)` pattern |\n| `zeros(...,'like',x)` | Eliminates temporaries | `0 * x` to create zeros |\n| Copy-on-write sharing | Shares backing memory | Same array assigned to multiple places |\n| Dense → sparse | O(N²) → O(N·bw) | `zeros(N,N)` where N > 10000 |\n\n### Step 4: Implement Optimizations\n\nApply the identified patterns. Focus only on the hotspots identified in Step 2 — do not apply patterns everywhere.\n\n### Step 5: Measure Optimized Memory\n\nRe-measure using the same method as Step 1:\n\n```matlab\nm0 = memory;\noptimizedFunction(inputs);\nm1 = memory;\ndeltaOpt = m1.MemUsedMATLAB - m0.MemUsedMATLAB;\nreduction = 1 - deltaOpt \u002F deltaBytes;\nfprintf('Optimized: %.2f MB (%.0f%% reduction)\\n', deltaOpt\u002F1e6, reduction*100);\n```\n\n### Step 6: Verify Correctness\n\nEvery optimization must produce the same results:\n\n```matlab\noriginal = originalFunction(inputs);\noptimized = optimizedFunction(inputs);\nmaxErr = max(abs(original(:) - optimized(:)));\nfprintf('Max error: %.2e\\n', maxErr);\nassert(maxErr \u003C 1e-10, 'Results differ!');\n```\n\n### Step 7: Report Results\n\nSummarize the memory optimization with baseline, optimized, reduction percentage, correctness check, and patterns applied.\n\n## Key Rules\n\n1. **Never propose optimizations based solely on reading source code** — always measure and profile first\n2. **Verify correctness** — memory optimizations must produce identical results\n3. **Clear variables early** — free memory as soon as data is no longer needed\n4. **Avoid growing arrays** — preallocate or use cell collection\n5. **Break chains** — sequential assignment reduces peak memory vs chained expressions\n6. **Watch for copies** — MATLAB copies on write; reuse variables to avoid duplicates\n\n## Platform Notes\n\n- **Windows:** `memory` command returns full statistics (`MemUsedMATLAB`, etc.)\n- **Linux\u002FmacOS:** `memory` errors (\"not supported on this platform\"). Use `whos` for variable sizes, Java `Runtime.getRuntime` for heap usage, or OS-level RSS via `system('ps ...')`\n- **`profile -memory`:** Works on all platforms but is undocumented since R2016a. When unavailable, use `whos` snapshots before\u002Fafter function calls.\n\nCopyright 2026 The MathWorks, Inc.\n","# MATLAB Memory Optimization Workflow\n\nSystematic 7-step workflow for finding and fixing memory bottlenecks in MATLAB code.\n\n## When to Use\n\n- User gets out-of-memory errors running MATLAB code\n- User wants to reduce memory usage of their MATLAB program\n- User wants to process larger datasets without running out of memory\n- User asks to profile or measure memory allocations\n\n## When NOT to Use\n\n- The bottleneck is execution speed, not memory (use `matlab-optimize-performance`)\n- The memory issue is in compiled C\u002FMEX code that can't be changed at the M-code level\n- Memory usage is dominated by I\u002FO buffers (memory-mapped files, database connections)\n\n## The 7-Step Workflow\n\n### Step 1: Establish Memory Baseline\n\nMeasure current memory usage before making changes.\n\n```matlab\nm0 = memory;\ntargetFunction(inputs);\nm1 = memory;\ndeltaBytes = m1.MemUsedMATLAB - m0.MemUsedMATLAB;\nfprintf('Memory delta: %.2f MB\\n', deltaBytes \u002F 1e6);\n```\n\nWhen `memory` errors (Linux\u002FmacOS), use `whos` for variable sizes or Java runtime for heap:\n```matlab\ninfo = whos('result');\nfprintf('Variable size: %.2f MB\\n', info.bytes \u002F 1e6);\n```\n\n### Step 2: Profile Memory Allocations\n\nFind where memory is being allocated.\n\n```matlab\nprofile('-memory', 'on');\nfor iter = 1:5\n    targetFunction(inputs);\nend\nprofile off;\np = profile('info');\nft = p.FunctionTable;\n[~, idx] = sort([ft.TotalMemAllocated], 'descend');\nfor i = 1:min(15, numel(idx))\n    f = ft(idx(i));\n    fprintf('%-40s %10.2f MB\\n', f.FunctionName, f.TotalMemAllocated\u002F1e6);\nend\n```\n\nIf `TotalMemAllocated` fields are zero, fall back to `whos` snapshots before\u002Fafter each function call.\n\n**Key things to look for:**\n- Functions with high \"Allocated\" but low \"Freed\" — memory is retained\n- Functions called many times with moderate allocations — total adds up\n- Large gaps between Allocated and Freed — temporaries accumulating\n\n### Step 3: Identify Optimization Opportunities\n\nBased on profiling, identify which patterns apply. See `references\u002Fmemory-patterns.md` for code examples.\n\n| Pattern | Typical Reduction | Look For |\n|---------|-------------------|----------|\n| Cell collection + `vertcat` | O(N²) → O(N) | `[arr; newRow]` inside loops |\n| Implicit expansion over `repmat` | Eliminates full copy | `repmat(A, [1 1 K])` for broadcasting |\n| Clear variables when done | Immediate reclamation | Large arrays used only in early steps |\n| Break chained expressions | 1 fewer peak temporary | `a.*b.*c.\u002Fd` all alive at once |\n| Reuse variables (overwrite in-place) | Avoids output allocation | Separate variables for each step |\n| `max`\u002F`min` instead of masking | Eliminates logical temporary | `x .* (x > 0)` pattern |\n| `zeros(...,'like',x)` | Eliminates temporaries | `0 * x` to create zeros |\n| Copy-on-write sharing | Shares backing memory | Same array assigned to multiple places |\n| Dense → sparse | O(N²) → O(N·bw) | `zeros(N,N)` where N > 10000 |\n\n### Step 4: Implement Optimizations\n\nApply the identified patterns. Focus only on the hotspots identified in Step 2 — do not apply patterns everywhere.\n\n### Step 5: Measure Optimized Memory\n\nRe-measure using the same method as Step 1:\n\n```matlab\nm0 = memory;\noptimizedFunction(inputs);\nm1 = memory;\ndeltaOpt = m1.MemUsedMATLAB - m0.MemUsedMATLAB;\nreduction = 1 - deltaOpt \u002F deltaBytes;\nfprintf('Optimized: %.2f MB (%.0f%% reduction)\\n', deltaOpt\u002F1e6, reduction*100);\n```\n\n### Step 6: Verify Correctness\n\nEvery optimization must produce the same results:\n\n```matlab\noriginal = originalFunction(inputs);\noptimized = optimizedFunction(inputs);\nmaxErr = max(abs(original(:) - optimized(:)));\nfprintf('Max error: %.2e\\n', maxErr);\nassert(maxErr \u003C 1e-10, 'Results differ!');\n```\n\n### Step 7: Report Results\n\nSummarize the memory optimization with baseline, optimized, reduction percentage, correctness check, and patterns applied.\n\n## Key Rules\n\n1. **Never propose optimizations based solely on reading source code** — always measure and profile first\n2. **Verify correctness** — memory optimizations must produce identical results\n3. **Clear variables early** — free memory as soon as data is no longer needed\n4. **Avoid growing arrays** — preallocate or use cell collection\n5. **Break chains** — sequential assignment reduces peak memory vs chained expressions\n6. **Watch for copies** — MATLAB copies on write; reuse variables to avoid duplicates\n\n## Platform Notes\n\n- **Windows:** `memory` command returns full statistics (`MemUsedMATLAB`, etc.)\n- **Linux\u002FmacOS:** `memory` errors (\"not supported on this platform\"). Use `whos` for variable sizes, Java `Runtime.getRuntime` for heap usage, or OS-level RSS via `system('ps ...')`\n- **`profile -memory`:** Works on all platforms but is undocumented since R2016a. When unavailable, use `whos` snapshots before\u002Fafter function calls.\n\nCopyright 2026 The MathWorks, Inc.\n",{"name":5,"license":25,"metadata":26,"description":7},"MathWorks BSD-3-Clause",{"author":27,"version":28},"MathWorks","1.1","master","49e49abf2f670d429e0b7e2c0349739c3fdd5cbe","skills\u002Fmatlab-optimize-memory",5,"https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium","https:\u002F\u002Fgithub.com\u002Fstanfish06","https:\u002F\u002Fwww.stanfish.dev\u002F","2026-11-14 21:31:37",{"source":8,"skillName":5,"commands":38,"prompt":48,"zipAvailable":49},[39,42,45],{"tool":40,"command":41},"npx","npx skills add stanfish06\u002Fskillquarium --skill matlab-optimize-memory",{"tool":43,"command":44},"bunx","bunx skills add stanfish06\u002Fskillquarium --skill matlab-optimize-memory",{"tool":46,"command":47},"pnpm","pnpm dlx skills add stanfish06\u002Fskillquarium --skill matlab-optimize-memory","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fmatlab-optimize-memory\u002FSKILL.md",true,[51,56,62],{"path":52,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":55,"sourceHtmlUrl":16},"LICENSE.md","LICENSE","许可证",1482,{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"manifest.yaml","REFERENCE","参考文档",401,"https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fmatlab-optimize-memory\u002Fmanifest.yaml",{"path":63,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":64,"sourceHtmlUrl":65},"references\u002Fmemory-patterns.md",1648,"https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fmatlab-optimize-memory\u002Freferences\u002Fmemory-patterns.md",[67,75,84,91,98,105],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":71,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":20},"01M76ZJTRVA456GD7K8Y3EP82H","zarr-python","Stores and queries chunked N-D scientific arrays with Zarr-Python 3, including codecs, sharding, S3\u002FGCS storage, and NumPy\u002FDask\u002FXarray integration. Use for array layout, bounded I\u002FO, format migration, or scientific metadata preservation.","MIT","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fzarr-python\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":79,"licenseFileUrl":80,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":20},"01M76ZJQZ15Q1HKC5V85NHE325","yeet","Publish local changes to GitHub by confirming scope, committing intentionally, pushing the branch, and opening a draft PR through the GitHub app from this plugin, with `gh` used only as a fallback where connector coverage is insufficient.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fyeet\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fyeet\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":79,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":20},"01M76ZJ8ASZ4QYQ70Y6SBA4Z4S","xarray","N-dimensional labeled arrays and datasets in Python. Built on top of NumPy and Dask. It introduces labels in the form of dimensions, coordinates, and attributes on top of raw NumPy-like arrays, making data analysis in physical sciences more intuitive and less error-prone. Use for working with multi-dimensional scientific data, NetCDF\u002FGRIB\u002FZarr files, climate\u002Fweather\u002Foceanographic datasets, remote sensing, geospatial imaging, large out-of-memory datasets with Dask, and labeled array operations.","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fxarray\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":71,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":20},"01M76ZHFBXD6VXPQ02VCEG202B","writing-mstest-tests","Use when asked to fix, rewrite, update, improve, modernize, show corrected code for, or explain existing MSTest tests or MSTest-specific configuration. Use for \"review\" when corrected code or edits are wanted, even for one pasted assertion or passing tests with bad failure output. Covers expected\u002Factual labels; generic Boolean, collection, string, numeric, null, identity, exception, hard-cast, and object[] checks; TestContext\u002Flifecycle; timeout\u002Fcancellation; OS\u002FCI conditions, retry, cleanup, parallelization, MSTest.Sdk project setup, and MSTESTxxxx. Honor the installed MSTest version. DO NOT USE to design new test cases (code-testing), perform report-only audits, create project files rather than explain MSTest setup, run tests, migrate frameworks, or handle non-MSTest\u002Fnon-.NET code.","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fwriting-mstest-tests\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":71,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":20},"01M76ZDFDF4N88RH6HSYGS7GP2","wgs-prs","End-to-end WGS to polygenic risk score pipeline. Takes paired-end FASTQ files (or a pre-existing VCF) through nf-core\u002Fsarek for variant calling, applies VCF QC (normalisation, hard filtering, Ti\u002FTv and Het\u002FHom checks), then computes polygenic risk scores via the PGS Catalog. Fills the FASTQ to VCF gap upstream of the gwas-prs skill.","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fwgs-prs\u002FSKILL.md",[],[],{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":79,"licenseFileUrl":109,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":20},"01M76ZCC1SC68J42QK4MDC8RCG","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fwebapp-testing\u002FSKILL.md",[],[]]