when I using ECS ,EntityManager.SetSharedComponentData report "hashmap is full"

I creating a 3d city in unity3d with ECS
it have so many diff building mesh(160K+)
when I run my code like:

            Entity entity = em.Instantiate(src);
            RenderMesh renderMesh = new RenderMesh()
            {
                mesh = m,
                material = mat,
                castShadows = ShadowCastingMode.Off,
                receiveShadows = false,
            };
            em.SetSharedComponentData<RenderMesh>(entity, renderMesh);

I get err msg : “HashMap is full” and unity cash.

But I try to creat less buildings(<10K) , the code run success.

is NativeMultiHashMap had a bug?

I came across few hard limitation like this one myself and my solution to these so far is to just spin more World instances to accommodate them. If one starts thinking about Worlds as buckets of data and related processes (systems) this even starts makes more sense to organize everything this way.


Also if I understand it correctly these aren’t limitations per se but decently wise optimization. Because while every World preallocates memory to speed up processes:

  • it cannot preallocate infinite/all memory (shocker I know)
  • dynamic allocations would be bad for performance

Both alternatives would defeat whole point of ECS so arbitrary buffer lengths had to be choosen here and there.