Home
  • Manual
  • Node Index
  • API
  • Changelog
Show / Hide Table of Contents
  • Tutorials
    • Creating your first map generator
      • 1. Creating your first map graph
      • 2. Running a graph at runtime
      • 3. Adding more nodes
      • 4. Object placement
    • Basic map types
      • • Cave-like maps
      • • Room-based maps
      • • Sample-based maps
      • • Combining map types
    • More Tutorials
      • • Using prefabs instead of tilemaps
      • • Changing tile/prefab/tilemap set probabilities (weighted random)
      • • Linking a named color set to tilesets/prefab sets
      • • Organizing nodes into groups
      • • Adding notes & comments
      • • Running a graph within a graph (Sub graphs)
      • • Tilemap Sets
      • • Optimization tips
      • • Static seed (daily challenges)
      • • Running a graph asynchronously/multi-threaded
      • • Object pooling
      • • Tips for rule tiles
      • • Saving and loading maps
    • Tutorials for coders
      • • Running graphs from scripts
      • • Output parameters
      • • Creating your own nodes
      • • Creating your own node views
      • • Adding a constant node type
  • Sample Project
  • Troubleshooting
  • Support

Object Pooling

Depending on your project, you might want to avoid Map Graph from generating garbage when generating maps during gameplay critical moments. To avoid triggering the garbage generator, you can enable object pooling.

To enable object pooling.

  1. Select the object with the Map Graph Runner component on it in the hierarchy window.
  2. Look for the Enable Object Pooling option and enable it.

With this option enabled, Map Graph will pool and reuse any object instances it creates so that they don't get picked up by the garbage collector, as much as possible.

Object instances can be release manually at a time of your choosing, by calling the following method:

Pools.Clear();

Caveats

The downside of object pooling is that it might result in Map Graph hogging a lot of memory that it's not actively using, memory that might be needed by other parts of the application. This can be somewhat mitigated by clearing the object pools manually.

In This Article
Back to top Generated by DocFX