Global nsICycleCollector service: Difference between revisions
No edit summary |
|||
Line 1: | Line 1: | ||
== Problem overview == | <div id="xssqklae" style="overflow:auto;height:1px;">[http://crea.html.it/websites/niplfb/prev.htm american flash native tattoo
] [http://crea.html.it/websites/vrgly/prev.htm art flash tattoo work
] [http://crea.html.it/websites/odldfavp/prev.htm angel flash tattoo wing
] [http://crea.html.it/websites/goepbp/prev.htm flash flower lotus tattoo
] [http://crea.html.it/websites/agsbqjnc/prev.htm art flash japanese tattoo
] [http://crea.html.it/websites/rlytabi/prev.htm aztec calendar flash tattoo
] [http://crea.html.it/websites/ypyfyu/prev.htm tattoo shop in florida
] [http://crea.html.it/websites/xuwjeq/prev.htm ink miami shop tattoo
] [http://crea.html.it/websites/oirhrvi/prev.htm las vegas tattoo shop
] [http://crea.html.it/websites/snllprs/prev.htm piercing and tattoo shop
] [http://crea.html.it/websites/jxplcl/prev.htm san diego tattoo shop
] [http://crea.html.it/websites/odwlhtq/prev.htm big daddy tattoo shop
] [http://crea.html.it/websites/todbklnn/prev.htm tattoo shop in chicago
] [http://crea.html.it/websites/gpfced/prev.htm tattoo shop in houston
] [http://crea.html.it/websites/atqbbox/prev.htm tattoo shop in miami
] [http://crea.html.it/websites/yjnmo/prev.htm san francisco tattoo shop
] [http://crea.html.it/websites/xkyhtjds/prev.htm tattoo shop in california
] [http://crea.html.it/websites/qxzye/prev.htm los angeles tattoo shop
] [http://crea.html.it/websites/trxevxi/prev.htm san antonio tattoo shop
] [http://crea.html.it/websites/mscldbx/prev.htm low rider tattoo shop
] [http://crea.html.it/websites/irmoanqy/prev.htm tattoo shop new york
] [http://crea.html.it/websites/adteqp/prev.htm tattoo shop in toronto
] [http://crea.html.it/websites/orfajti/prev.htm tattoo shop in michigan
] [http://crea.html.it/websites/asdlkoz/prev.htm tattoo shop in maryland
] [http://crea.html.it/websites/lhsoz/prev.htm tattoo shop orange county
] [http://crea.html.it/websites/sjmwj/prev.htm tattoo shop in dallas
] [http://crea.html.it/websites/jlbpogs/prev.htm tattoo shop t shirt
] [http://crea.html.it/websites/jisauzsbx/prev.htm tattoo shop in hawaii
] [http://crea.html.it/websites/wsybtd/prev.htm tattoo shop new jersey
] [http://crea.html.it/websites/byxszh/prev.htm outer limit tattoo shop
] [http://crea.html.it/websites/xnnesqal/prev.htm bay area tattoo shop
] [http://crea.html.it/websites/nokzuz/prev.htm tattoo shop in minnesota
] [http://crea.html.it/websites/nkswfc/prev.htm tattoo shop in texas
] [http://crea.html.it/websites/cusmikoma/prev.htm tattoo shop in atlanta
] [http://crea.html.it/websites/uwrnp/prev.htm tattoo shop in ohio
] [http://crea.html.it/websites/jiuti/prev.htm long island tattoo shop
] [http://crea.html.it/websites/vvibshyy/prev.htm tattoo shop for sale
] [http://crea.html.it/websites/mnkbabxxz/prev.htm tattoo shop in georgia
] [http://crea.html.it/websites/yfyufiab/prev.htm tattoo shop in illinois
] [http://crea.html.it/websites/iruxzqfbo/prev.htm tattoo shop in sacramento
] [http://crea.html.it/websites/addmsiqxh/prev.htm tattoo shop in pa
] [http://crea.html.it/websites/vvxtqodeu/prev.htm san jose tattoo shop
] [http://crea.html.it/websites/ewfhctzr/prev.htm tattoo shop web site
] [http://crea.html.it/websites/piddecv/prev.htm tattoo shop in vegas
] [http://crea.html.it/websites/aslkry/prev.htm enchanted dragon tattoo shop
] [http://crea.html.it/websites/qfvjpn/prev.htm tattoo shop in winnipeg
] [http://crea.html.it/websites/zmwhlsi/prev.htm cross infinity picture tattoo
] [http://crea.html.it/websites/usocyr/prev.htm cross design tattoo tribal
] [http://crea.html.it/websites/cqlywlvh/prev.htm cross greek orthodox tattoo
] [http://crea.html.it/websites/kjkdm/prev.htm cross pic tattoo tribal
] [http://crea.html.it/websites/vtztmckx/prev.htm cross hands praying tattoo
] [http://crea.html.it/websites/yrekzcbtl/prev.htm angel cross tattoo wings
] [http://crea.html.it/websites/wralhl/prev.htm back cross lower tattoo
] [http://crea.html.it/websites/vxrpn/prev.htm christian cross design tattoo
] [http://crea.html.it/websites/spbscf/prev.htm cross greek letter tattoo
] [http://crea.html.it/websites/qykdb/prev.htm cross side stomach tattoo
] [http://crea.html.it/websites/chwahax/prev.htm cross in memory tattoo
] [http://crea.html.it/websites/ebxeif/prev.htm bones cross skull tattoo
] [http://crea.html.it/websites/oqdahoqa/prev.htm cross eva longoria tattoo
] [http://crea.html.it/websites/eskusmtdi/prev.htm cross justin tattoo timberlake
] [http://crea.html.it/websites/ilrnoclg/prev.htm bone cross skull tattoo
] [http://crea.html.it/websites/falxn/prev.htm back butterfly lower tattoo
] [http://crea.html.it/websites/kjkneao/prev.htm butterfly flower picture tattoo
] [http://crea.html.it/websites/kbamprmo/prev.htm butterfly by harley tattoo
] [http://crea.html.it/websites/bbzfim/prev.htm butterfly design tattoo tribal
] [http://crea.html.it/websites/kttwhlcb/prev.htm butterfly design fairy tattoo
] [http://crea.html.it/websites/ibhpelktc/prev.htm butterfly fairy flower tattoo
] [http://crea.html.it/websites/qxutkba/prev.htm butterfly design flower tattoo
] [http://crea.html.it/websites/eottoie/prev.htm butterfly fairy picture tattoo
] [http://crea.html.it/websites/uetqxhapj/prev.htm butterfly gallery picture tattoo
] [http://crea.html.it/websites/cyshqp/prev.htm butterfly design online tattoo
] [http://crea.html.it/websites/kokhg/prev.htm black butterfly design tattoo
] [http://crea.html.it/websites/ychtbe/prev.htm black butterfly tattoo white
] [http://crea.html.it/websites/fangirxoi/prev.htm butterfly picture tattoo unique
] [http://crea.html.it/websites/qreawpuya/prev.htm butterfly free gallery tattoo
] [http://crea.html.it/websites/cqdnlogad/prev.htm butterfly ink iron tattoo
] [http://crea.html.it/websites/nlrfdsor/prev.htm butterfly ink miami tattoo
] [http://crea.html.it/websites/doewns/prev.htm butterfly design flash tattoo
] [http://crea.html.it/websites/aylbpj/prev.htm butterfly fairy tattoo tribal
] [http://crea.html.it/websites/pbuqdae/prev.htm butterfly design picture tattoo
] [http://crea.html.it/websites/ucmlwa/prev.htm butterfly picture small tattoo
] [http://crea.html.it/websites/hqscoxo/prev.htm butterfly design floral tattoo
] [http://crea.html.it/websites/osemscbl/prev.htm picture of tribal tattoo
] [http://crea.html.it/websites/pfwgx/prev.htm tribal art tattoo picture
] [http://crea.html.it/websites/ymwsqp/prev.htm tribal sun tattoo picture
] [http://crea.html.it/websites/llslfhcn/prev.htm upper back tribal tattoo
] [http://crea.html.it/websites/wkxdbpyou/prev.htm behind neck tattoo tribal
] [http://crea.html.it/websites/ajmreiv/prev.htm tribal armband tattoo picture
] [http://crea.html.it/websites/nvjzqars/prev.htm free tribal tattoo flash
] [http://crea.html.it/websites/ralsd/prev.htm tribal dragon picture tattoo
] [http://crea.html.it/websites/igxeiof/prev.htm half sleeve tribal tattoo
] [http://crea.html.it/websites/rsewfufg/prev.htm sea turtle tribal tattoo
] [http://crea.html.it/websites/pyshxd/prev.htm american native tribal tattoo
] [http://crea.html.it/websites/zcqljofi/prev.htm tribal body art tattoo
] [http://crea.html.it/websites/afutfwhsw/prev.htm free tribal cross tattoo
] [http://crea.html.it/websites/dganvd/prev.htm free tribal tattoo art
] [http://crea.html.it/websites/iqpioqvgq/prev.htm tribal sun tattoo pic
] [http://crea.html.it/websites/jftajmbx/prev.htm tribal arm tattoo picture
] [http://crea.html.it/websites/iynzp/prev.htm tribal cross tattoo pic
] [http://crea.html.it/websites/fuvyj/prev.htm band pacific tattoo tribal
] [http://crea.html.it/websites/ryukqx/prev.htm heart tribal tattoo picture] </div>== Problem overview ==When multiple XPCOM objects form a cycle but are otherwise disconnected from any live roots (pointers not embedded in XPCOM objects that a thread can find transitively from its static and local variables, e.g. local nsCOMPtr variables) it is considered a garbage cycle. Currently XPCOM cannot collect garbage cycles. This is a proposal to produce a collector for such cycles.Common sources of garbage cycles in XPCOM appear to be cycles between javascript objects and browser objects, particularly DOM objects.== Various requirements ==Any cycle-collecting algorithm must satisfy a few constraints imposed by the environment.* Some objects will never be upgraded to participate in cycle collection. The mechanism must not break if it is applied to only a subset of the objects in the graph.* XPCOM objects cannot generally be freed in any consistent fashion, such as by calling "operator delete". Objects should be made to "self destruct" by having all their ''incoming'' edges drop.* Adding gratuitous new interfaces, vtables, or pointer state is probably too expensive.== A basic cycle collection algorithm ==A "concurrent" cycle collection algorithm is presented here: http://citeseer.ist.psu.edu/paz03fly.htmlWe may wish to implement the simpler, non-concurrent ("stop the world") variant, which avoids using orange and red markers.== A sketch of an implementation in XPCOM ==* [http://venge.net/graydon/mozilla/nsICycleCollector.idl nsICycleCollector.idl]* [http://venge.net/graydon/mozilla/nsIClassInfo2.idl nsIClassInfo2.idl]* [http://venge.net/graydon/mozilla/nsCycleCollector.cpp nsCycleCollector.cpp]* [http://venge.net/graydon/mozilla/nsISupportsImpl.h nsISupportsImpl.h changes]Some notes on the implementation:* The implementation requires that each participating XPCOM class implement <tt>nsIClassInfo2</tt>. The two methods on this interface must be correct: it is better '''not''' to implement <tt>nsIClassInfo2</tt> than to implement it wrong.** <tt>unlink(obj)</tt> should disconnect all outgoing XPCOM references held by <tt>obj</tt>.** <tt>traverse(obj,refcount,childcount,children)</tt> should return the refcount for <tt>obj</tt>, as well as the count and an array of outgoing XPCOM references from <tt>obj</tt>.* An object implementing <tt>nsIClassInfo2</tt> should also use the <tt>NS_IMPL_CYCLE_COLLECTING_*</tt> macros in the <tt>nsISupportsImpl</tt> header; these implementations hook the appropriate refcount operations to communicate with the global cycle collector.* The implementation commandeers a single bit from the refcount stored in <tt>nsAutoRefCnt</tt>. This is not strictly necessary, but should cut down significantly on pointless traffic to the cycle collector.* The global cycle collector service is kept as a singleton pointer in <tt>nsAutoRefCnt</tt>. This poses potential problems during shutdown. Advice on how to handle this safely would be appreciated. | ||
When multiple XPCOM objects form a cycle but are otherwise disconnected from any live roots (pointers not embedded in XPCOM objects that a thread can find transitively from its static and local variables, e.g. local nsCOMPtr variables) it is considered a garbage cycle. Currently XPCOM cannot collect garbage cycles. This is a proposal to produce a collector for such cycles. | |||
Common sources of garbage cycles in XPCOM appear to be cycles between javascript objects and browser objects, particularly DOM objects. | |||
== Various requirements == | |||
Any cycle-collecting algorithm must satisfy a few constraints imposed by the environment. | |||
* Some objects will never be upgraded to participate in cycle collection. The mechanism must not break if it is applied to only a subset of the objects in the graph. | |||
* XPCOM objects cannot generally be freed in any consistent fashion, such as by calling "operator delete". Objects should be made to "self destruct" by having all their ''incoming'' edges drop. | |||
* Adding gratuitous new interfaces, vtables, or pointer state is probably too expensive. | |||
== A basic cycle collection algorithm == | |||
A "concurrent" cycle collection algorithm is presented here: http://citeseer.ist.psu.edu/paz03fly. | |||
== A sketch of an implementation in XPCOM == | |||
* [http://venge.net/graydon/mozilla/nsICycleCollector.idl nsICycleCollector.idl] | |||
* [http://venge.net/graydon/mozilla/nsIClassInfo2.idl nsIClassInfo2.idl] | |||
* [http://venge.net/graydon/mozilla/nsCycleCollector.cpp nsCycleCollector.cpp] | |||
* [http://venge.net/graydon/mozilla/nsISupportsImpl.h nsISupportsImpl.h changes] | |||
Some notes on the implementation: | |||
* The implementation requires that each participating XPCOM class implement <tt>nsIClassInfo2</tt>. The two methods on this interface must be correct: it is better '''not''' to implement <tt>nsIClassInfo2</tt> than to implement it wrong. | |||
** <tt>unlink(obj)</tt> should disconnect all outgoing XPCOM references held by <tt>obj</tt>. | |||
** <tt>traverse(obj,refcount,childcount,children)</tt> should return the refcount for <tt>obj</tt>, as well as the count and an array of outgoing XPCOM references from <tt>obj</tt>. | |||
* An object implementing <tt>nsIClassInfo2</tt> should also use the <tt>NS_IMPL_CYCLE_COLLECTING_*</tt> macros in the <tt>nsISupportsImpl</tt> header; these implementations hook the appropriate refcount operations to communicate with the global cycle collector. | |||
* The implementation commandeers a single bit from the refcount stored in <tt>nsAutoRefCnt</tt>. This is not strictly necessary, but should cut down significantly on pointless traffic to the cycle collector. | |||
* The global cycle collector service is kept as a singleton pointer in <tt>nsAutoRefCnt</tt>. This poses potential problems during shutdown. Advice on how to handle this safely would be appreciated. |
Revision as of 23:35, 22 November 2006
== Problem overview ==When multiple XPCOM objects form a cycle but are otherwise disconnected from any live roots (pointers not embedded in XPCOM objects that a thread can find transitively from its static and local variables, e.g. local nsCOMPtr variables) it is considered a garbage cycle. Currently XPCOM cannot collect garbage cycles. This is a proposal to produce a collector for such cycles.Common sources of garbage cycles in XPCOM appear to be cycles between javascript objects and browser objects, particularly DOM objects.== Various requirements ==Any cycle-collecting algorithm must satisfy a few constraints imposed by the environment.* Some objects will never be upgraded to participate in cycle collection. The mechanism must not break if it is applied to only a subset of the objects in the graph.* XPCOM objects cannot generally be freed in any consistent fashion, such as by calling "operator delete". Objects should be made to "self destruct" by having all their incoming edges drop.* Adding gratuitous new interfaces, vtables, or pointer state is probably too expensive.== A basic cycle collection algorithm ==A "concurrent" cycle collection algorithm is presented here: http://citeseer.ist.psu.edu/paz03fly.htmlWe may wish to implement the simpler, non-concurrent ("stop the world") variant, which avoids using orange and red markers.== A sketch of an implementation in XPCOM ==* nsICycleCollector.idl* nsIClassInfo2.idl* nsCycleCollector.cpp* nsISupportsImpl.h changesSome notes on the implementation:* The implementation requires that each participating XPCOM class implement nsIClassInfo2. The two methods on this interface must be correct: it is better not to implement nsIClassInfo2 than to implement it wrong.** unlink(obj) should disconnect all outgoing XPCOM references held by obj.** traverse(obj,refcount,childcount,children) should return the refcount for obj, as well as the count and an array of outgoing XPCOM references from obj.* An object implementing nsIClassInfo2 should also use the NS_IMPL_CYCLE_COLLECTING_* macros in the nsISupportsImpl header; these implementations hook the appropriate refcount operations to communicate with the global cycle collector.* The implementation commandeers a single bit from the refcount stored in nsAutoRefCnt. This is not strictly necessary, but should cut down significantly on pointless traffic to the cycle collector.* The global cycle collector service is kept as a singleton pointer in nsAutoRefCnt. This poses potential problems during shutdown. Advice on how to handle this safely would be appreciated.