Friday, 15 March 2013

c# - Free Memory after ImageBrush was set to null in WPF -


My app (music player) has a feature called "Game Mode" which prevents every background function except music, and I I want some storage too for free

eg I have a background image on the base grid in my grid that I have set in that way

  BaseGrid.Background = new ImageBrush ("image");   

I did something like this in the Game Mode method

  BaseGrid.Background = null; GC.Collect ();   

But for the first time, no memory was released for the first time, when I worked for it the second time, or if I paste the message box. Show the method between Nulling and GC. Collect it also works.

So my question is to set the background as a blank asynchronous operation which takes some time and GC. The collector does not see the unused object when it is said so soon after nulling or is it another problem?

anytime you call

  gc Compiler ();   

You should call

  GC WaitForPendingFinalizer ()   

also

No comments:

Post a Comment