LaurentGomila/SFML.Net — Issue #5: Let the CLR know how much memory you use
Author: Oberon00
Created: 2011-10-31 08:55:42+00:00
State: open

Currently the garbage collector thinks that e.g. an Image is just the size of one IntPtr big, although it might occupy several MBs of memory. This is not optimal. You can read the following in the [MSDN Library](http://msdn.microsoft.com/en-us/library/system.gc.addmemorypressure.aspx#remarksToggle):

> In determining when to schedule garbage collection, the runtime takes into account how much managed memory is
> allocated. If a small managed object allocates a large amount of unmanaged memory, the runtime takes into account only the
> managed memory, and thus underestimates the urgency of scheduling garbage collection.

To solve this problem you should use [GC.AddMemoryPressure](http://msdn.microsoft.com/en-us/library/system.gc.addmemorypressure.aspx) (and of course [GC.RemoveMemoryPressure](http://msdn.microsoft.com/en-us/library/system.gc.removememorypressure.aspx)).