GC.AddMemoryPressure in C#

Posted by ssheldon on Stack Overflow See other posts from Stack Overflow or by ssheldon
Published on 2010-04-11T17:53:14Z Indexed on 2010/04/11 18:03 UTC
Read the original article Hit count: 402

Filed under:
|
|

I am writing an application in C# that makes use of a 3rd party COM DLL, this dll creates a lot of resources (like bitmaps, video, data structures) in unmanaged memory. While digging around I came across the following call for the Garbage Collector:

GC.AddMemoryPressure(long long bytesAllocated)

It is documented in MSDN here:

http://msdn.microsoft.com/en-us/library/system.gc.addmemorypressure.aspx

This sounds like something I should be calling since this external dll is createing a lot of resources the CLR is unaware of.

I guess I have two questions...

  1. How do I know how much memory pressure to add when the dll is 3rd party and it's not possible for me to know exactly how much memory this dll is allocating.
  2. How important is it to do this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about gc