Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH_Document dispose does not clean up Param_Point memory footprint #698

Open
dionjansen opened this issue Dec 19, 2024 · 0 comments
Open

Comments

@dionjansen
Copy link

I have been doing some investigation into memory use of our Rhino runtime when run from the command line and came across what seems to be a memory leak.

Grasshopper models that contain point params do not seem to clean up (part of) their memory footprint.

I am using Rhino 7.37.24107.15001 on Windows 11 Pro, version 22H2 (build: 22621.4317)

I run the following sequence in a loop:

var io = new Grasshopper.Kernel.GH_DocumentIO();
io.Open(modelPath)
using (var doc = io.Document)
{
  Console.WriteLine($"(Document loaded. TotalMemory: {MB(GC.GetTotalMemory(false))})");
}

GC.Collect();
GC.WaitForPendingFinalizers();
var currentMemory = GC.GetTotalMemory(true);

var diff = currentMemory - previousMemory;

Console.WriteLine($"Completed. TotalMemory: {MB(currentMemory)}, Diff: {KB(diff)}");
previousMemory = currentMemory;

Full runnable project for repro with test definitions in the zip attached: SampleRhino.zip

When the model contains, say numbersliders, panels, surface components memory of the document is cleaned up as expected. However when opening and disposing a document with point params about 1KB per param remains for each param after dispose:

Loading RhinoCommon version 7.37.24107.15001
Running main loop for model 'definitions\points.gh', press CTRL+C to quit anytime. TotalMemory: 3MB
Completed. TotalMemory: 16MB, Diff: 13453KB
Completed. TotalMemory: 16MB, Diff: 116KB
Completed. TotalMemory: 16MB, Diff: 117KB
Completed. TotalMemory: 16MB, Diff: 115KB
Completed. TotalMemory: 16MB, Diff: 125KB
Completed. TotalMemory: 17MB, Diff: 117KB
Completed. TotalMemory: 17MB, Diff: 113KB
Completed. TotalMemory: 17MB, Diff: 116KB
Completed. TotalMemory: 17MB, Diff: 113KB
Completed. TotalMemory: 17MB, Diff: 131KB
Completed. TotalMemory: 17MB, Diff: 122KB
Completed. TotalMemory: 17MB, Diff: 121KB
Completed. TotalMemory: 17MB, Diff: 109KB
Completed. TotalMemory: 18MB, Diff: 128KB
Completed. TotalMemory: 18MB, Diff: 88KB
Completed. TotalMemory: 18MB, Diff: 115KB
Completed. TotalMemory: 18MB, Diff: 129KB
Completed. TotalMemory: 18MB, Diff: 114KB
Completed. TotalMemory: 18MB, Diff: 104KB
Completed. TotalMemory: 18MB, Diff: 114KB
Completed. TotalMemory: 18MB, Diff: 131KB
Completed. TotalMemory: 18MB, Diff: 115KB
Completed. TotalMemory: 19MB, Diff: 116KB
Completed. TotalMemory: 19MB, Diff: 116KB
Completed. TotalMemory: 19MB, Diff: 129KB
Completed. TotalMemory: 19MB, Diff: 100KB
Completed. TotalMemory: 19MB, Diff: 115KB
Completed. TotalMemory: 19MB, Diff: 115KB
Completed. TotalMemory: 19MB, Diff: 115KB
Completed. TotalMemory: 19MB, Diff: 115KB
Completed. TotalMemory: 19MB, Diff: 115KB
Completed. TotalMemory: 20MB, Diff: 115KB
Completed. TotalMemory: 20MB, Diff: 115KB
Interrupted, stopping app ..
Completed. TotalMemory: 20MB, Diff: 115KB
Done

This in the attached project the points.gh definition contains 100 points.

When looking at the memory profile at each iteration, what stands out to me is that CentralSettings.PreviewGumballsChanged Event seems to be keeping the point params in memory through its attributes: image

Question

Do I need to do anything extra to the document to dispose point parameters?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant