I am writing a script for the videogame Space Engineers. Due to the… interesting nature of the scripting API, making use of static variables causes a memory leak. In order to avoid that, I store variables I’d want to be static as non-static and pass them to classes through their constructor whenever necessary.
While writing some domain logic using one of these passed variables (which is a reference to a class), I wondered if it would be better (read: less performance intensive) to not pass the variable and perform part of the logic in my service class instead (though writing this sentence has made me reconsider), as I would not have to pass the reference variable to every instance of the domain object that way (and the logic I was writing had to go through the service class anyway).
I tried searching StackOverflow and googling, but to no avail.
Does having multiple references to the same object have a significant impact on speed and/or RAM usage? Or rather, What are the performance effects of having multiple references to a single object this way vs. having only one reference in a service class?