c# - How can I reduce the garbage generation in this situation -
my game has gotten point generating garbage , resulting in long gc times. i've been going around , reducing lot of garbage generated there's 1 spot that's allocating large amount of memory , i'm stuck on how can resolve this.
my game minecraft-type world generates new regions walk. have large, variable size array allocated on creation of new region used store vertex data terrain. after array filled data, it's passed slimdx datastream can used rendering.
the problem fact variable-size array , needs passed slimdx, calls gchandle.alloc on it. since variable size, may have resized in order reuse it. can't allocate max sized array each region because require impossibly large amounts of memory. can't use list because of gchandle business slimdx.
so far, resizing array when needs made bigger seems plausible option me, may not work out , pain implement. i'd need keep track of actual size of array separately , use unsafe code pointer array , pass slimdx. may end using such large amount of memory have go , reduce size of arrays down minimum needed.
i'm hesitant jump @ solution , know if sees better solutions this.
i'd suggest tighter integration slimdx library. it's open source dig in , find critical path need rendering. integrate tighter using dma-style memory sharing approach.
Comments
Post a Comment