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

fix more memory leaks when starting and closing DynamoRevit #14366

Merged
merged 3 commits into from
Sep 1, 2023

Conversation

mjkkirschner
Copy link
Member

@mjkkirschner mjkkirschner commented Sep 1, 2023

Purpose

This PR fixes more memory leaks when starting and closing DynamoRevit and creating a single new workspace each time.

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated
  • This PR contains no files larger than 50 MB

Release Notes

fix additional memory leaks.

Reviewers

…ynamoDS#14344)

* fixing mem leaks in progress

* fix test and remove todo
get rid of redudant try/catch
cleanup log event in docs browser extension
replace item produced lambda with named method
fix broken dispose logic in nodeautocompletesearchcontrol - it was always hanging onto static event
implement dispose on viewextensioncommandexec
on dynamoviewmodel dispose, also dispose all workspaces - their remove methods are not called...
fix entry added lambda in searchviewmodel
dynamoview now disposes workspace view and node autocomplete search - TODO here.
workspaceview implement idisposable and cleans up view model subscriptions
direct manip extension was not cleaning up settings prop changed.
graph meta data view was not cleaning up current workspace cleared event
attempt to cleanup browser com refs... not sure this is helping
@@ -47,7 +47,7 @@ public NodeAutoCompleteSearchControl()
Application.Current.Deactivated += CurrentApplicationDeactivated;
if (Application.Current.MainWindow != null)
{
Application.Current.MainWindow.Closing -= NodeAutoCompleteSearchControl_Unloaded;
Application.Current.MainWindow.Closing += NodeAutoCompleteSearchControl_Unloaded;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjkkirschner mjkkirschner merged commit 8817293 into DynamoDS:master Sep 1, 2023
@mjkkirschner mjkkirschner deleted the mastermem2 branch September 1, 2023 21:39
@@ -403,6 +403,7 @@ public override void Dispose()
{
cate.DisposeTree();
}
Model.EntryAdded += AddEntry;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be -=?

@mjkkirschner
Copy link
Member Author

mjkkirschner commented Sep 6, 2023 via email

//TODO code smell.
var workspaceView = this.ChildOfType<WorkspaceView>();
workspaceView?.Dispose();
(workspaceView?.NodeAutoCompleteSearchBar?.Child as IDisposable)?.Dispose();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to dispose this specific control?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the NodeAutoCompleteSearchControl has a dispose method which does not seem to be called from anywhere else.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor point but how about disposing it inside the workspaceview's dispose method - would be cleaner.

var settings = GetRunSettings(WorkspaceModel);
if (settings != null)
{
settings.PropertyChanged -= OnRunSettingsPropertyChanged;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does need to be unsubscribed here?

Copy link
Member Author

@mjkkirschner mjkkirschner Sep 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because when Dynamo is shutdown the SetWorkspaceModel call above is not called. So we do it somewhere in the shutdown/dispose hook path of this extension.

In a context like Revit where Dynamo can be shutdown and started over and over, this leads to leaks. In Sandbox it's not an issue.

@@ -266,6 +266,7 @@ private void MarkCurrentWorkspaceModified()
public void Dispose()
{
this.viewLoadedParams.CurrentWorkspaceChanged -= OnCurrentWorkspaceChanged;
this.viewLoadedParams.CurrentWorkspaceCleared += OnCurrentWorkspaceChanged;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure it's not -=?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, it's probably a copy paste error, but I will double check and add it to #14379

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

Successfully merging this pull request may close these issues.

3 participants