Applied Energistics 2

Applied Energistics 2

137M Downloads

FacadeItemModel does not clear baseModel cache when a resource reload is requested

asiekierka opened this issue ยท 2 comments

commented

What this causes is multiple instances of ModelLoader (as referenced by ModelLoader$VanillaModelWrapper, as it holds a reference to the parent class) to be kept in memory as soon as something requests a second resource refresh, causing greatly increased additional memory load.

"private IModel baseModel" should be set to null in an event which is called before model baking but during every resource reload. TextureStitchEvent.Pre might be a good place for it.

commented

Thanks. Actually ModelLoaderRegistry.getModel() appears to use a cached now, so it should be fine to use it instead of lazy evaluated field. The overhead should not be important compared to whatever else is done during model baking and it is certainly better than relying on some event to try and cleanup something vanilla/forge produced.

commented

Yeah, just using ModelLoaderRegistry.getModel() directly is fine.

Please fix it ASAP, though, as the size of the dangling ModelLoader can get pretty high - on the pack I've tested (280 mods) it caused a 1GB difference in memory usage, which was over 25% of its overall usage (with FoamFix - the ratio is smaller, but still considerable without FoamFix)!