Keep you max memory not too large, direct memory isn’t triggering the GC so you have to make sure the GC is run more often. Setting a larger heap size makes the out of memory error happen sooner (kind of counter-intuitive before you start to think about it).
Yeah, set your direct memory really large. 1 gig is probably good. And then keep your heap memory low enough so that GC runs periodically.
For example, in Mythruna I used to have both of these set to 1 gig and frequently had out of memory errors when walking around at full clip. Now that I have the max heap set to 512 meg the game runs better and I rarely see out of memory errors anymore.
Direct memory seems to get cleared as part of the non-full generational GC… which is good.