I have an application that works heavily with many custom objects that are created inside methods and never needed outside of them. The whole structure is (in my opinion) very good object oriented and uses Services, Utilities and a DI-Model.
Now, as I ran my first "large" tests, I quickly encountered OutOfMemoryExceptions. Now, I don't just want to increase the heap space and be done with it, as I can imagine that will not solve the problem but rather delay it until my application has grown more and encounter the same problem then.
I'm looking for some simple and easy to implement solutions, tips and snippets that help an application deal with garbage collection and heap spaces, especially when it comes to many loops that operate with object creation.
Something like "don't create objects in loops, create them before the loop and overwrite it within" and the sorts.