With memory blocks that are large (“hundreds of megabytes”), it should be relationally easy to find out who uses them and where (you can put 10–20 such blocks into memory anyway). Since ypu plans to use such amounts of mmeory, you need to carefully reduce memory usage - i.e. A simple copy of the entire buffer will take non-trivial time.
When you are done with a specific block, you can force the GC. This sounds like a reasonable use of the GC.Collect API - you did using a huge portion of all avaialble memory.
You can also consider switching to smaller (64k) blocks and linking them together if it works for your application. This is more consistent with garbage collection and can provide more flexibility for your application.
source share