0

I'm trying to get my application to release some memory, but according to some posts I've read, the GC will seldom clear the Large Object Heap.

The application is built on Silverlight, initially v4, but I've upgraded to v5.

I've read this some posts giving this WaitForFullGCComplete method as a solution. I've been trying to implement this, but I don't get this option. I've changed the SL version, hoping it'd be available on v5, but no joy.

msdn states on version information this .NET Framework Supported in: 4.5, 4, 3.5 SP1, 3.0 SP2, 2.0 SP2 and .NET Framework Client Profile Supported in: 4, 3.5 SP1, but I have found no information on Silverlight support

Does anyone know if it is possible to get this method running on SL and how?

Thanks in advance

Ricardo Appleton
  • 679
  • 10
  • 22
  • I don't know if this methd is available in Silverlight or not, but I do know that most of the time, calling any method of the GC class is a symptom of something broken in your architecture or your architecture, and not the right solution. The only legitimate case I know of of triggering a garbage collection manually is to do it as "safe" times in a real time application. – Falanwe Sep 18 '14 at 13:44
  • That is right. I 'inherited' the application, and am trying to solve a number of memory leaks, and that came up as an answer in some posts – Ricardo Appleton Sep 18 '14 at 14:02
  • Silverlight uses the .NETCore build of the CLR and the BCL. A very trimmed version, nice so that web browsers don't have to download a huge installer before displaying a page. So, no, of course it isn't available. It doesn't do anything for you anyway, the method was meant for servers. Avoid asking XY questions. – Hans Passant Sep 18 '14 at 15:46
  • @Falanwe: maybe you want to extend your thinking about calling GC methods by reading http://stackoverflow.com/a/478177/480982. Needn't be a real time app, could just be to prevent OutOfMemoryException. – Thomas Weller Sep 19 '14 at 10:18
  • @ThomasW. the exemple given by Jon Skeet sums up to "force a collection when the user won't notice it". That's a case of exactly what I said: any UI is a realtime application (it has to run continuously or else the use will see freezes) and you can pick up the time you deem safe for a collection. `GC.Collect` might prevent an OutOfMemoryException (very unlikely though, as the GC will more likely trigger on its own before the exception is thrown), but that's only hiding the problem that caused the exception in the first place – Falanwe Sep 19 '14 at 12:10
  • @Falanwe: that's what I thought as well, but I had enough OOMs where .NET didn't trigger GC when needed but they would have helped. I'll see if I can provide a sample application for that (might take a while). – Thomas Weller Sep 19 '14 at 14:10
  • @Thomas W, Yeah, I had read that post, and indeed the issue is upon closing a very large form, which is not being released from memory... Anyway, calling GC explicitly isn't doing any good anyway – Ricardo Appleton Sep 19 '14 at 15:19

1 Answers1

0

As you can see from other methods like String.Contains(), Silverlight is listed as a supported platform.

Since Silverlight is not listed on GC.WaitForFullGCComplete(), you can assume that it simply does not exist.

Thomas Weller
  • 55,411
  • 20
  • 125
  • 222