Please note: this project is inactive since early 2006

 
4.7.1 Finalizing an EditingContext: breaking reference cycles

When an EditingContext is about to be deleted, its dispose() method gets called. This is followed with a two-step procedure, acting on each object registered within the EditingContext:

  1. Un-registered: Each object held by the EC is unregistered and detached, and, if no other reference to that object exists, it will thus be ready to be garbage collected - however, other objects in the EditingContext are likely to hold a reference to it especially if your model defines relationships between objects (see below). From this point on, obj.editingContext() returns None.

  2. Invalidated: Then, depending on the value returned by invalidatesObjectsWhenFinalized():

The default behaviour for an EditingContext is to invalidate its objects. The reason for this is that the objects you fetch or create within an EditingContext are most of the time in relation with each other; these relations tend to create reference cycles between them, hence making it harder for the garbage collection to notice they are not referenced anymore. Invalidating each object actually breaks the reference cycles which helps the garbage collecter to detect that they should be destroyed.

Comments are welcome: Sebastien Bigaret / Modeling Home Page
Hosted by:SourceForge.net Logo