Skip to content

Inherit from NotificationObject to avoid memory leak in data binding#2890

Merged
ke-yu merged 1 commit intoDynamoDS:masterfrom
ke-yu:inotifypropertychanged
Oct 30, 2014
Merged

Inherit from NotificationObject to avoid memory leak in data binding#2890
ke-yu merged 1 commit intoDynamoDS:masterfrom
ke-yu:inotifypropertychanged

Conversation

@ke-yu
Copy link
Contributor

@ke-yu ke-yu commented Oct 29, 2014

This pull request is part of attempt to fix memory leak on Revit.

Related pull request:

Looking at some retention paths, notice because some objects are referenced from system object, RevitDynamoModel is not released (see images attached at the end of comment).

These objects looks innocent, but according to this article, memory could easily be leak due to data binding. The solution is "Anything involved in a databinding should implement INotifyPropertyChanged" (:-()

I didn't dig too deep. But inheriting from NotificationObject removes these objects on RevitDynamoModel's reference retention path.

RevitDynamoModel is still referenced by other objects, but locally I've fixed it. I'll send the fix in other pull request.

3

  • ShortCutBarItem

    1

  • StartPageListItem

2

@benglin
Copy link
Contributor

benglin commented Oct 30, 2014

The INotifyPropertyChanged bit was so bizarre... but good to know, thanks for sharing! LGTM!

@ikeough
Copy link
Contributor

ikeough commented Oct 30, 2014

I even remember reading that article, but it was hard to parse exactly what it meant. Basically any object that ever participates in data binding needs to implement INotifyPropertyChanged (we use NotificationObject). I know for a fact that we do exactly what is shown in that article in a number of places. I think we're safe with our nodes, ports, connectors and workspaces (anything inheriting from ModelBase). We'll just have to be super diligent in the future about not reintroducing this.

Is there an automated memory test that we can add to track this?

LGTM.

ke-yu added a commit that referenced this pull request Oct 30, 2014
Inherit from NotificationObject to avoid memory leak in data binding
@ke-yu ke-yu merged commit 25f86ee into DynamoDS:master Oct 30, 2014
@ke-yu ke-yu deleted the inotifypropertychanged branch October 30, 2014 06:30
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