AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified Apache-2.0 Self-run

Memory Management

skill-medy-gribkov-arcana-memory-management · by medy-gribkov

Game memory optimization, object pooling, garbage collection tuning, and efficient resource management for target platforms.

No reviews yet
0 installs
34 views
0.0% view→install

Install

$ agentstack add skill-medy-gribkov-arcana-memory-management

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-medy-gribkov-arcana-memory-management)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
2mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Memory Management? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Memory Management

Memory Architecture

┌─────────────────────────────────────────────────────────────┐
│                    GAME MEMORY LAYOUT                        │
├─────────────────────────────────────────────────────────────┤
│  STACK (Fast, Auto-managed):                                 │
│  ├─ Local variables                                         │
│  ├─ Function parameters                                     │
│  └─ Return addresses                                        │
│                                                              │
│  HEAP (Slower, Manual/GC-managed):                           │
│  ├─ Dynamic allocations (new/malloc)                        │
│  ├─ Game objects                                            │
│  └─ Asset data                                              │
│                                                              │
│  STATIC (Fixed at compile time):                             │
│  ├─ Global variables                                        │
│  ├─ Static class members                                    │
│  └─ Constant data                                           │
│                                                              │
│  VRAM (GPU Memory):                                          │
│  ├─ Textures                                                │
│  ├─ Meshes                                                  │
│  └─ Render targets                                          │
└─────────────────────────────────────────────────────────────┘

Platform Memory Budgets

MEMORY BUDGET GUIDELINES:
┌─────────────────────────────────────────────────────────────┐
│  PLATFORM      │ TOTAL    │ GAME LOGIC │ ASSETS   │ BUFFER │
├────────────────┼──────────┼────────────┼──────────┼────────┤
│  Mobile Low    │ 512 MB   │ 50 MB      │ 350 MB   │ 112 MB │
│  Mobile High   │ 2 GB     │ 200 MB     │ 1.5 GB   │ 300 MB │
│  Console       │ 8 GB     │ 500 MB     │ 6 GB     │ 1.5 GB │
│  PC Min        │ 4 GB     │ 300 MB     │ 3 GB     │ 700 MB │
│  PC High       │ 16 GB    │ 1 GB       │ 12 GB    │ 3 GB   │
│  VR            │ 8 GB     │ 400 MB     │ 6 GB     │ 1.6 GB │
└────────────────┴──────────┴────────────┴──────────┴────────┘

VRAM BUDGETS:
┌─────────────────────────────────────────────────────────────┐
│  Mobile:    512 MB - 1 GB                                   │
│  Console:   8-12 GB (shared with RAM)                       │
│  PC Low:    2-4 GB                                          │
│  PC High:   8-16 GB                                         │
└─────────────────────────────────────────────────────────────┘

Object Pooling

// ✅ Production-Ready: Generic Object Pool
public class ObjectPool where T : class
{
    private readonly Stack _pool;
    private readonly Func _createFunc;
    private readonly Action _onGet;
    private readonly Action _onReturn;
    private readonly int _maxSize;

    public int CountActive { get; private set; }
    public int CountInPool => _pool.Count;

    public ObjectPool(
        Func createFunc,
        Action onGet = null,
        Action onReturn = null,
        int initialSize = 10,
        int maxSize = 100)
    {
        _createFunc = createFunc;
        _onGet = onGet;
        _onReturn = onReturn;
        _maxSize = maxSize;
        _pool = new Stack(initialSize);

        // Pre-warm pool
        for (int i = 0; i  0 ? _pool.Pop() : _createFunc();
        _onGet?.Invoke(item);
        CountActive++;
        return item;
    }

    public void Return(T item)
    {
        if (item == null) return;

        _onReturn?.Invoke(item);
        CountActive--;

        if (_pool.Count  _bulletPool;

    void Awake()
    {
        _bulletPool = new ObjectPool(
            createFunc: () => Instantiate(bulletPrefab).GetComponent(),
            onGet: bullet => bullet.gameObject.SetActive(true),
            onReturn: bullet => bullet.gameObject.SetActive(false),
            initialSize: 50,
            maxSize: 200
        );
    }

    public Bullet SpawnBullet(Vector3 position, Vector3 direction)
    {
        var bullet = _bulletPool.Get();
        bullet.Initialize(position, direction);
        bullet.OnDestroyed += () => _bulletPool.Return(bullet);
        return bullet;
    }
}

Garbage Collection Optimization

GC SPIKE PREVENTION:
┌─────────────────────────────────────────────────────────────┐
│  AVOID IN UPDATE/HOT PATHS:                                  │
│  ✗ new object()                                             │
│  ✗ string concatenation ("a" + "b")                         │
│  ✗ LINQ queries (ToList(), Where(), etc.)                   │
│  ✗ Boxing value types                                       │
│  ✗ Closures/lambdas capturing variables                     │
│  ✗ foreach on non-struct enumerators                        │
│                                                              │
│  DO INSTEAD:                                                 │
│  ✓ Object pooling                                           │
│  ✓ StringBuilder for strings                                │
│  ✓ Pre-allocated collections                                │
│  ✓ Struct-based data                                        │
│  ✓ Cache delegates                                          │
│  ✓ for loops with index                                     │
└─────────────────────────────────────────────────────────────┘
// ✅ Production-Ready: Allocation-Free Patterns
public class AllocationFreePatterns
{
    // ❌ BAD: Allocates every frame
    void BadUpdate()
    {
        string status = "Health: " + health + "/" + maxHealth; // Allocates
        var enemies = allEntities.Where(e => e.IsEnemy).ToList(); // Allocates
        foreach (var enemy in enemies) { } // May allocate enumerator
    }

    // ✓ GOOD: Zero allocations
    private StringBuilder _sb = new StringBuilder(64);
    private List _enemyCache = new List(100);

    void GoodUpdate()
    {
        // Reuse StringBuilder
        _sb.Clear();
        _sb.Append("Health: ").Append(health).Append("/").Append(maxHealth);

        // Reuse list, avoid LINQ
        _enemyCache.Clear();
        for (int i = 0; i  Nearby > Background                 │
│  • Async loading to avoid hitches                          │
└─────────────────────────────────────────────────────────────┘
// ✅ Production-Ready: Asset Streaming Manager
public class StreamingManager : MonoBehaviour
{
    [SerializeField] private float loadDistance = 50f;
    [SerializeField] private float unloadDistance = 100f;
    [SerializeField] private float unloadDelay = 5f;

    private Dictionary _zones = new();
    private Queue _loadQueue = new();

    void Update()
    {
        Vector3 playerPos = Player.Position;

        foreach (var zone in _zones.Values)
        {
            float distance = Vector3.Distance(playerPos, zone.Center);

            if (distance  unloadDistance && zone.IsLoaded)
            {
                StartCoroutine(UnloadZoneDelayed(zone, unloadDelay));
            }
        }
    }

    private IEnumerator LoadZoneAsync(StreamingZone zone)
    {
        zone.State = ZoneState.Loading;

        var operation = SceneManager.LoadSceneAsync(zone.SceneName, LoadSceneMode.Additive);
        operation.allowSceneActivation = false;

        while (operation.progress name;

    delete player; // Might be double-free
}

// ✅ C++: Smart pointers help (but optional)
void main() {
    auto player = std::make_unique("Bob");

    // Transfer ownership explicitly
    process_player(std::move(player));

    // player is now nullptr, safer but still manual
}

Key Difference: Rust enforces ownership rules at compile time. C++ smart pointers are opt-in and don't prevent logic errors like accessing moved-from objects. Rust makes memory safety the default, not an afterthought.


Use this skill: When optimizing memory usage, reducing frame stutters, or supporting mobile platforms.

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.