c# - Manual GC Gen2 data allocation -
i'm prototyping managed directx game engine before moving c++ syntax horror. let's i've got data (f.e. array or hashset of references) i'm sure it'll stay alive throughout whole application's life. since performance crucial here , i'm trying avoid lag spikes on generation promotion, i'd ask if there's way initialize object (allocate memory) straight ahead in gc's generation 2? couldn't find answer that, i'm pretty sure i've seen doing before.
alternatively since there no real need "manage" piece of memory, possible allocate unmanaged code, expose rest of code .net type?
you can't allocate directly in gen 2. allocations happen in either gen 0 or on large object heap (if 85000 bytes or larger). however, pushing gen 2 easy: allocate want go gen 2 , force gcs @ point. can call gc.getgeneration inspect generation of given object.
another thing keep pool of objects. i.e. instead of releasing objects , making them eligible gc, return them pool. reduces allocations , number of gcs well.
Comments
Post a Comment