Refunding is triggering a nasty memory leak on this.part.Modules.Add
Lisias opened this issue ยท 3 comments
This is a follow up from issue #21
TL;DR : Refunding was creating and destroying the fake Resource under demand. This was triggering a nasty bug on Unity's GC under heavy load, since this crappy excuse of a Game Engine is using spinlocks to halt the threads when the GC is working. This completely trashes the whole system: 8 threads waiting a spinlock and an i7 with 4 cores and 8 hyper-threads just gets down on its knees in pain.
Empirical tests pinpoint the this.part.Resources
as the culprit by the memory leak.
And... YEAH. I was right
There's something smelling funny on this.part.Resources.Add(PartResource)
. Brute forcing my way using this.part.Resources.Add(int, PartResource)
solved the memory leak and also that pesky log messages on KSP.log like this one:
[LOG 00:02:31.256] [PartSet]: Failed to add Resource 1566956177 to Simulation PartSet:60079 as corresponding Part Mk0 Liquid Fuel Fuselage-4274492751 SimulationResource was not found.
Fixed on commit 8395611