I am monitoring the consumption of my software's memory through dotMemory JetBrains.
I noticed that when I do a query through my repository, then if I close the window, I have left the object from which I made the call; my repository into memory, I used using and even dispose of my context but nothing remains .. in memory. What can I check?
Here is the offending code:
LoginViewModel.cs
using (DbContext = new Context())
{
   var creazioneDocumentoRepository = new RepositoryBase<CreazioneDocumento>(ctx);
   var creazioneDocumento = creazioneDocumentoRepository.Lista();
   if (creazioneDocumento == null || creazioneDocumento.Count == 0) 
      return;
   var decimaliQuantita = creazioneDocumento.Max(x => x.NumeroDecimaliQuantita);
   _NumeroDecimaliQuantita = decimaliQuantita != 0 && decimaliQuantita > 0 ? decimaliQuantita : 0;
   var decimaliPrezzo = creazioneDocumento.Max(x => x.NumeroDecimaliPrezzo);
   _NumeroDecimaliPrezzo = decimaliPrezzo != 0 && decimaliPrezzo > 0 ? decimaliPrezzo : 3;
   _NumeroDecimaliImponibile = 2;
   //   ctx.Dispose();
}
Doing debugging, I noticed that up to:
if (creazioneDocumento == null || creazioneDocumento.Count == 0) return;
the object is not remembered, but as soon as I run the "max" the object remains in memory.
Here is a screen shot from dotmemory:
Instead this screenshot tells me what are the methods that reference and keep in memory my loginviewmodel and I believe they are the two max:


 
     
     
    