Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
lblMessage.Text = New System.Text.StringBuilder("Garbage collection completed ").Append(Now.ToString).Append(".").ToString
However, running the app will update the label with the current time, but it doesn't look like GC is occurring. Real-time view in .NET MP shows the instances still in memory, but if I click the snapshot button in .NET MP, the GC appears to occur and all of the instances I expected to get collected did. I was under the impression that GC is a global thing, and you can call GC from a separate app and GC will take place. My test app seems to show otherwise. Is GC.Collect not global across the current machine? If it's not, how can I force a global GC such as .Net MP does, or is that not possible since it looks like .Net MP is loading the tested application on top of itself?
.NET Memory Profiler is able to initiate a garbage collection in the profiled process by using a profiling library that gets loaded into the profiled process.
I don't know of a simple way of forcing a GC in an external process or doing a machine wide GC. It is possible to perform it by using advanced techniques such as injecting code into the process using CreateRemoteThread, but I don't see any real use for this. Why do you want to perform a system wide garbage collection?
SciTech Software AB
Users browsing this forum: No registered users and 27 guests