There is no way to optimize the presented section. It seems to me very suitable. O . Net will take care of releasing the memory when it is possible and necessary and you do not need to worry about it in this case. At least for this section. It may even be that other parts have problems and are not allowing the release of memory.
I even have my doubts whether memory is really overloaded, whether you used reliable methods to determine this.
Maybe you have a very large data volume being loaded. There is another problem.
Did you need the refresh same? This may not be the best way. But even doing this every time ostecnicos receive a new object, the previous one will be free to be removed from memory when the Garbage Collector wish for.
Using the Entity Framework is not the most appropriate way to make the system lightweight. Not that it’s going to change much either but you certainly don’t even consider not using it.
Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?
– Maniero