Skip to content

Instantly share code, notes, and snippets.

@gamemachine
Created February 17, 2022 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gamemachine/f8f1781969ca2c63e5b43769797c88b1 to your computer and use it in GitHub Desktop.
Save gamemachine/f8f1781969ca2c63e5b43769797c88b1 to your computer and use it in GitHub Desktop.
using Unity.Collections;
using UnityEngine;
[ExecuteAlways]
public class TempAllocTest : MonoBehaviour
{
private NativeHashMap<int, int> Map;
private void OnEnable()
{
Map = new NativeHashMap<int, int>(64, Allocator.Persistent);
for(int i=0;i<1024 * 512;i++)
{
Map[i] = default;
}
}
private void OnDisable()
{
if (Map.IsCreated) Map.Dispose();
}
private void OnDrawGizmosSelected()
{
if (!Map.IsCreated) return;
var keys = Map.GetKeyArray(Allocator.Temp);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment