Opened 6 years ago

Closed 6 years ago

Last modified 17 months ago

#258 closed change (fixed)

[Typed objects] Implement a garbage collection mechanism

Reported by: trev Assignee: trev
Priority: P2 Milestone:
Module: Core Keywords:
Cc: Blocked By:
Blocking: #145, #393 Platform:
Ready: yes Confidential: no
Tester: Verified working: no
Review URL(s):

Description (last modified by trev)


Typed objects proposal doesn't specify any special garbage collection behavior, typed objects apparently get garbage collected just like any other JavaScript object. This isn't something we can implement, for us it is impossible to tell which typed objects are still in use. Reference counting should be the easiest solution, it will also allow us to run destructors when an object is freed.

What to change

Add ObjectBase.retain() and ObjectBase.release() methods that will be common to all typed objects. An object is created with reference count 1, the code creating it should always call ObjectBase.release() at some point (we'll eventually need static analysis to verify that it does). Any other code that want to hold on to the object should call ObjectBase.retain() and then ObjectBase.release() when the object is no longer needed. Typed references should do this automatically when their value is set, for regular JavaScript code we'll have to do it manually (hopefully a rare occasion).

Change History (5)

comment:1 Changed 6 years ago by trev

  • Owner set to trev
  • Status changed from new to assigned

comment:2 Changed 6 years ago by trev

  • Description modified (diff)

comment:3 Changed 6 years ago by trev

  • Review URL(s) modified (diff)
  • Status changed from assigned to reviewing

comment:4 Changed 6 years ago by trev

  • Blocking 393 added

comment:5 Changed 6 years ago by trev

  • Resolution set to fixed
  • Status changed from reviewing to closed
Note: See TracTickets for help on using tickets.