Re: Keeping a list of instances and garbage-collection

2009-03-31 Thread Sean Kelly
grauzone wrote: Sean Kelly wrote: == Quote from Sergey Gromov (snake.sc...@gmail.com)'s article Sun, 29 Mar 2009 17:42:48 -0400, Chad J wrote: Maybe what you are looking for are the GC.removeRoot or GC.removeRange functions which are available in both Phobos and Tango? http://www.dsource.org/p

Re: Keeping a list of instances and garbage-collection

2009-03-31 Thread grauzone
Actually, scratch that. Any 4 byte pattern can look like a pointer. Unless you manage to encode it in a way the 4 byte cells look like they're pointing into an address range not managed by the GC. For example, most OSes reserve the last 1 or 2 GBs for the kernel. If your byte quadruple looks li

Re: Keeping a list of instances and garbage-collection

2009-03-30 Thread grauzone
Sean Kelly wrote: == Quote from Sergey Gromov (snake.sc...@gmail.com)'s article Sun, 29 Mar 2009 17:42:48 -0400, Chad J wrote: Maybe what you are looking for are the GC.removeRoot or GC.removeRange functions which are available in both Phobos and Tango? http://www.dsource.org/projects/tango/doc

Re: Keeping a list of instances and garbage-collection

2009-03-30 Thread grauzone
Bill Baxter wrote: On Tue, Mar 31, 2009 at 7:37 AM, Christopher Wright wrote: grauzone wrote: Christopher Wright wrote: grauzone wrote: Jarrett Billingsley wrote: On Sun, Mar 29, 2009 at 4:42 PM, Leandro Lucarella wrote: This was discussed several times in the past. For example: http://w

Re: Keeping a list of instances and garbage-collection

2009-03-30 Thread Sean Kelly
== Quote from Sergey Gromov (snake.sc...@gmail.com)'s article > Sun, 29 Mar 2009 17:42:48 -0400, Chad J wrote: > > > > Maybe what you are looking for are the GC.removeRoot or GC.removeRange > > functions which are available in both Phobos and Tango? > > http://www.dsource.org/projects/tango/docs/cu

Re: Keeping a list of instances and garbage-collection

2009-03-30 Thread Sergey Gromov
Sun, 29 Mar 2009 17:42:48 -0400, Chad J wrote: > Simon TRENY wrote: >> Hello, >> >> I have a class "A" and I'd like to keep a list of all the created instances >> of this class. To do that, I have a static List!(A) in the A class and, in >> the constructor, I add each new instance to this list.

Re: Keeping a list of instances and garbage-collection

2009-03-30 Thread Bill Baxter
On Tue, Mar 31, 2009 at 7:37 AM, Christopher Wright wrote: > grauzone wrote: >> >> Christopher Wright wrote: >>> >>> grauzone wrote: Jarrett Billingsley wrote: > > On Sun, Mar 29, 2009 at 4:42 PM, Leandro Lucarella > wrote: >> >> This was discussed several times in t

Re: Keeping a list of instances and garbage-collection

2009-03-30 Thread Christopher Wright
grauzone wrote: Christopher Wright wrote: grauzone wrote: Jarrett Billingsley wrote: On Sun, Mar 29, 2009 at 4:42 PM, Leandro Lucarella wrote: This was discussed several times in the past. For example: http://www.digitalmars.com/d/archives/digitalmars/D/learn/weak_references_13301.html htt

Re: Keeping a list of instances and garbage-collection

2009-03-29 Thread Bill Baxter
On Mon, Mar 30, 2009 at 8:04 AM, bearophile wrote: > grauzone: >> First, I doubt this actually works. [...] To actually hide the pointer from >> the GC, you could XOR the size_t value with a constant.< > > This is may be a stupid idea: Can't the OP just allocate with > std.c.stdlib.malloc a bloc

Re: Keeping a list of instances and garbage-collection

2009-03-29 Thread bearophile
grauzone: > First, I doubt this actually works. [...] To actually hide the pointer from > the GC, you could XOR the size_t value with a constant.< This is may be a stupid idea: Can't the OP just allocate with std.c.stdlib.malloc a block of void* pointers (plus keep an int length too), fill them

Re: Keeping a list of instances and garbage-collection

2009-03-29 Thread grauzone
Christopher Wright wrote: grauzone wrote: Jarrett Billingsley wrote: On Sun, Mar 29, 2009 at 4:42 PM, Leandro Lucarella wrote: This was discussed several times in the past. For example: http://www.digitalmars.com/d/archives/digitalmars/D/learn/weak_references_13301.html http://www.digitalma

Re: Keeping a list of instances and garbage-collection

2009-03-29 Thread Bill Baxter
Part of the reason I wrote it and made it available was to serve as a focal point for such critiques. If you think it doesn't work and can fix it, please do so! --bb On Mon, Mar 30, 2009 at 7:00 AM, grauzone wrote: > Jarrett Billingsley wrote: >> >> On Sun, Mar 29, 2009 at 4:42 PM, Leandro Luc

Re: Keeping a list of instances and garbage-collection

2009-03-29 Thread Christopher Wright
grauzone wrote: Jarrett Billingsley wrote: On Sun, Mar 29, 2009 at 4:42 PM, Leandro Lucarella wrote: This was discussed several times in the past. For example: http://www.digitalmars.com/d/archives/digitalmars/D/learn/weak_references_13301.html http://www.digitalmars.com/d/archives/digitalma

Re: Keeping a list of instances and garbage-collection

2009-03-29 Thread grauzone
Jarrett Billingsley wrote: On Sun, Mar 29, 2009 at 4:42 PM, Leandro Lucarella wrote: This was discussed several times in the past. For example: http://www.digitalmars.com/d/archives/digitalmars/D/learn/weak_references_13301.html http://www.digitalmars.com/d/archives/digitalmars/D/learn/Soft_wea

Re: Keeping a list of instances and garbage-collection

2009-03-29 Thread Chad J
Simon TRENY wrote: > Hello, > > I have a class "A" and I'd like to keep a list of all the created instances > of this class. To do that, I have a static List!(A) in the A class and, in > the constructor, I add each new instance to this list. This gives me the > following code: > > class A { >

Re: Keeping a list of instances and garbage-collection

2009-03-29 Thread Jarrett Billingsley
On Sun, Mar 29, 2009 at 4:42 PM, Leandro Lucarella wrote: > > This was discussed several times in the past. For example: > http://www.digitalmars.com/d/archives/digitalmars/D/learn/weak_references_13301.html > http://www.digitalmars.com/d/archives/digitalmars/D/learn/Soft_weak_references_8264.html

Re: Keeping a list of instances and garbage-collection

2009-03-29 Thread Leandro Lucarella
Simon TRENY, el 29 de marzo a las 16:33 me escribiste: > Hello, > > I have a class "A" and I'd like to keep a list of all the created > instances of this class. To do that, I have a static List!(A) in the > A class and, in the constructor, I add each new instance to this list. > This gives me the

Keeping a list of instances and garbage-collection

2009-03-29 Thread Simon TRENY
Hello, I have a class "A" and I'd like to keep a list of all the created instances of this class. To do that, I have a static List!(A) in the A class and, in the constructor, I add each new instance to this list. This gives me the following code: class A { private static List!(A) s_instance