Evgenie Tivaniuk

Evgenie Tivaniuk

  • NA
  • 82
  • 11.2k

Need to release memory from unused images (Dispose?)

Sep 11 2017 4:14 AM
Hello,
I am making a game, and want to unload images when they aren't needed.
For now I am just setting their sources to null:
 
  1. imgExample.Source = null;  
 
But this isn't enough.
 
I already tried Freezing, but it doesn't seem to help much.
 
I read that their is such thing like "Dispose()" that seem to unload all the memory, in such cases, but I don't know how to use it.
 
I tried:
 
  1. imgExample.Dispose();  
 
But it didn't work, it seems I am missing either some kind of variable, or a using directive.
 
What can be done in this situation? 

Answers (4)