Cpp2IL
Cpp2IL copied to clipboard
High memory usage when building AsmResolver outputs due to no sharing
When building AsmResolver assemblies, Constant objects are not shared (realistically we only need one of each type-value pair), resulting in thousands of duplicate objects being created and massively increasing memory usage.
E.g. a method with 64 parameters (which does happen with VRC!) each of which has a default value, may result in 64 constants being created, even if most of those constants are the same (e.g. the null constant, Class/00 00 00 00).
This could probably be alleviated, at least for the null constant, and some common other ones like integer zero, boolean values, etc, by caching these constant values, significantly reducing memory pressure. Sharing between assemblies should not be a problem.