Re: GC object finalization not guaranteed

2009-04-25 Thread Daniel Keep
Michel Fortin wrote: > On 2009-04-19 09:10:12 -0400, Daniel Keep > said: > >> Walter Bright wrote: >>> Leandro Lucarella wrote: Close a connection gracefully for example, I guess (I mean, send a "bye" packed, not just close the socket abruptly). Same for closing files writin

Re: GC object finalization not guaranteed

2009-04-25 Thread Michel Fortin
On 2009-04-19 09:10:12 -0400, Daniel Keep said: Walter Bright wrote: Leandro Lucarella wrote: Close a connection gracefully for example, I guess (I mean, send a "bye" packed, not just close the socket abruptly). Same for closing files writing some mark or something. They can be risky when fin

Re: GC object finalization not guaranteed

2009-04-19 Thread Unknown W. Brackets
Personally, I usually use destructors to clean up or to decrement use counts, bleach secure data, etc. but it should be guaranteed that if data is no longer allocated, the destructor is called. That may be elsewhere in the spec, though. Also, hardware failure should always be expected: Webse

Re: GC object finalization not guaranteed

2009-04-19 Thread Leandro Lucarella
Christopher Wright, el 18 de abril a las 22:06 me escribiste: > Walter Bright wrote: > >Leandro Lucarella wrote: > >>You missed the point. I'm not talking about freeing the memory. I'm > >>talking about finalizers. A finalizer could send a "bye" packet throgh the > >>net. That can't be handled by t

Re: GC object finalization not guaranteed

2009-04-19 Thread Leandro Lucarella
Leandro Lucarella, el 19 de abril a las 13:08 me escribiste: > Don, el 19 de abril a las 07:35 me escribiste: > > Leandro Lucarella wrote: > > >I think shared memory is an example of memory resource that's not freed by > > >the OS on program exit. > > > > Really? That sounds like an OS memory leak

Re: GC object finalization not guaranteed

2009-04-19 Thread Leandro Lucarella
Don, el 19 de abril a las 07:35 me escribiste: > Leandro Lucarella wrote: > >I think shared memory is an example of memory resource that's not freed by > >the OS on program exit. > > Really? That sounds like an OS memory leak. Security issue, too: run > your program, allocated shared memory, then

Re: GC object finalization not guaranteed

2009-04-19 Thread Leandro Lucarella
Unknown W. Brackets, el 18 de abril a las 16:51 me escribiste: > Well, I guess it would be doable to guarantee destruction, but *only* if > order of destruction was not guaranteed. Yes, of course, order *can't* be guaranteed (unless you add read/write barriers and a lot of overhead at least =) >

Re: GC object finalization not guaranteed

2009-04-19 Thread Christopher Wright
Daniel Keep wrote: Walter Bright wrote: Leandro Lucarella wrote: Close a connection gracefully for example, I guess (I mean, send a "bye" packed, not just close the socket abruptly). Same for closing files writing some mark or something. They can be risky when finalization is not deterministic

Re: GC object finalization not guaranteed

2009-04-19 Thread Daniel Keep
Walter Bright wrote: > Leandro Lucarella wrote: >> Close a connection gracefully for example, I guess (I mean, send a "bye" >> packed, not just close the socket abruptly). Same for closing files >> writing some mark or something. They can be risky when finalization is >> not >> deterministic thou

Re: GC object finalization not guaranteed

2009-04-19 Thread Robin KAY
Don wrote: [snip] I think shared memory is an example of memory resource that's not freed by the OS on program exit. Really? That sounds like an OS memory leak. Security issue, too: run your program, allocated shared memory, then exit. Repeat until all memory is exhausted. Run your program

Re: GC object finalization not guaranteed

2009-04-18 Thread Don
Leandro Lucarella wrote: Don, el 18 de abril a las 23:43 me escribiste: I don't understand why D even has finalizers. Can they do anything useful? Yes. I use them to manage GPU memory/resources. Another are wrapper classes around manually allocated arrays (to avoid the false pointer problem with

Re: GC object finalization not guaranteed

2009-04-18 Thread Christopher Wright
Walter Bright wrote: Leandro Lucarella wrote: You missed the point. I'm not talking about freeing the memory. I'm talking about finalizers. A finalizer could send a "bye" packet throgh the net. That can't be handled by the OS. That shouldn't be handled by a finalizer. A "bye" packet can be h

Re: GC object finalization not guaranteed

2009-04-18 Thread Walter Bright
Leandro Lucarella wrote: You missed the point. I'm not talking about freeing the memory. I'm talking about finalizers. A finalizer could send a "bye" packet throgh the net. That can't be handled by the OS. That shouldn't be handled by a finalizer. A "bye" packet can be handled by a static dest

Re: GC object finalization not guaranteed

2009-04-18 Thread Jason House
Walter Bright Wrote: > Leandro Lucarella wrote: > > Close a connection gracefully for example, I guess (I mean, send a "bye" > > packed, not just close the socket abruptly). Same for closing files > > writing some mark or something. They can be risky when finalization is not > > deterministic thou

Re: GC object finalization not guaranteed

2009-04-18 Thread Unknown W. Brackets
Well, I guess it would be doable to guarantee destruction, but *only* if order of destruction was not guaranteed. In other words, at the end, the GC would not scan, it would just destroy. Scanning is a problem, due to cycles and various other things, but destroying all roots would be potentia

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Unknown W. Brackets, el 18 de abril a las 16:16 me escribiste: > The simple solution is this: > > 1. If your class object only involves memory, freed OS handles, etc., it > should be used as-is. This is most class objects. Destructors are > needed to clamp resource use (see File class.) A File

Re: GC object finalization not guaranteed

2009-04-18 Thread Unknown W. Brackets
The simple solution is this: 1. If your class object only involves memory, freed OS handles, etc., it should be used as-is. This is most class objects. Destructors are needed to clamp resource use (see File class.) 2. If your class object involves hardware handles, transactional assurance,

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Leandro Lucarella, el 18 de abril a las 19:36 me escribiste: > Rainer Deyke, el 18 de abril a las 16:18 me escribiste: > > Leandro Lucarella wrote: > > > You missed the point. I'm not talking about freeing the memory. I'm > > > talking about finalizers. A finalizer could send a "bye" packet throgh

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Rainer Deyke, el 18 de abril a las 16:18 me escribiste: > Leandro Lucarella wrote: > > You missed the point. I'm not talking about freeing the memory. I'm > > talking about finalizers. A finalizer could send a "bye" packet throgh the > > net. That can't be handled by the OS. > > It can't be handle

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Don, el 18 de abril a las 23:43 me escribiste: > >>I don't understand why D even has finalizers. Can they do anything useful? > >Yes. I use them to manage GPU memory/resources. Another are wrapper classes > >around manually allocated arrays (to avoid the false pointer problem with > >very > >lar

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Fawzi Mohamed, el 18 de abril a las 23:41 me escribiste: > >>when the main thread ends other threads might be running, and removing > >>memory they are using is not necessarily a good idea. > >Then I guess gc_term() should be invoked when all threads have terminated. > >Is there any technical diffi

Re: GC object finalization not guaranteed

2009-04-18 Thread Rainer Deyke
Leandro Lucarella wrote: > You missed the point. I'm not talking about freeing the memory. I'm > talking about finalizers. A finalizer could send a "bye" packet throgh the > net. That can't be handled by the OS. It can't be handled by the GC either, because: - This would require a high-level wra

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Fawzi Mohamed, el 18 de abril a las 23:43 me escribiste: > >If thread_joinAll() is called before gc_term(), I can't see how a thread > >could be still running when gc_term() is called. So, in terms of threads, > >I don't see a problem here. > > daemon theads are not joined So, you can keep thread

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Walter Bright, el 18 de abril a las 14:34 me escribiste: > Leandro Lucarella wrote: > >Close a connection gracefully for example, I guess (I mean, send a "bye" > >packed, not just close the socket abruptly). Same for closing files > >writing some mark or something. They can be risky when finalizati

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Walter Bright, el 18 de abril a las 14:33 me escribiste: > Leandro Lucarella wrote: > >The current GC implementation don't call finalizers for data that's still > >reference when the program *ended* (this is allowed by the specs, so it's > >fine, the question is why it's allowed by the specs). > >

Re: GC object finalization not guaranteed

2009-04-18 Thread Don
Robert Jacques wrote: On Sat, 18 Apr 2009 16:25:32 -0400, Don wrote: Leandro Lucarella wrote: Robert Jacques, el 18 de abril a las 11:56 me escribiste: On Sat, 18 Apr 2009 11:24:14 -0400, Leandro Lucarella wrote: I've just found out[1] this[2]: The garbage collector is not guaranteed

Re: GC object finalization not guaranteed

2009-04-18 Thread Fawzi Mohamed
On 2009-04-18 23:22:21 +0200, Leandro Lucarella said: Leandro Lucarella, el 18 de abril a las 18:03 me escribiste: Fawzi Mohamed, el 18 de abril a las 22:48 me escribiste: On 2009-04-18 22:25:32 +0200, Don said: Leandro Lucarella wrote: Robert Jacques, el 18 de abril a las 11:56 me escrib

Re: GC object finalization not guaranteed

2009-04-18 Thread Fawzi Mohamed
On 2009-04-18 23:03:11 +0200, Leandro Lucarella said: Fawzi Mohamed, el 18 de abril a las 22:48 me escribiste: On 2009-04-18 22:25:32 +0200, Don said: Leandro Lucarella wrote: Robert Jacques, el 18 de abril a las 11:56 me escribiste: On Sat, 18 Apr 2009 11:24:14 -0400, Leandro Lucarella

Re: GC object finalization not guaranteed

2009-04-18 Thread Walter Bright
Leandro Lucarella wrote: Close a connection gracefully for example, I guess (I mean, send a "bye" packed, not just close the socket abruptly). Same for closing files writing some mark or something. They can be risky when finalization is not deterministic though. Scoped objects should be used fo

Re: GC object finalization not guaranteed

2009-04-18 Thread Walter Bright
Leandro Lucarella wrote: The current GC implementation don't call finalizers for data that's still reference when the program *ended* (this is allowed by the specs, so it's fine, the question is why it's allowed by the specs). The why is because of speed. What's the point of running a gc pause

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Leandro Lucarella, el 18 de abril a las 18:03 me escribiste: > Fawzi Mohamed, el 18 de abril a las 22:48 me escribiste: > > On 2009-04-18 22:25:32 +0200, Don said: > > > > >Leandro Lucarella wrote: > > >>Robert Jacques, el 18 de abril a las 11:56 me escribiste: > > >>>On Sat, 18 Apr 2009 11:24:14

Re: GC object finalization not guaranteed

2009-04-18 Thread Robert Jacques
On Sat, 18 Apr 2009 16:25:32 -0400, Don wrote: Leandro Lucarella wrote: Robert Jacques, el 18 de abril a las 11:56 me escribiste: On Sat, 18 Apr 2009 11:24:14 -0400, Leandro Lucarella wrote: I've just found out[1] this[2]: The garbage collector is not guaranteed to run the destruc

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Fawzi Mohamed, el 18 de abril a las 22:48 me escribiste: > On 2009-04-18 22:25:32 +0200, Don said: > > >Leandro Lucarella wrote: > >>Robert Jacques, el 18 de abril a las 11:56 me escribiste: > >>>On Sat, 18 Apr 2009 11:24:14 -0400, Leandro Lucarella > >>>wrote: > I've just found out[1] this

Re: GC object finalization not guaranteed

2009-04-18 Thread Fawzi Mohamed
On 2009-04-18 22:25:32 +0200, Don said: Leandro Lucarella wrote: Robert Jacques, el 18 de abril a las 11:56 me escribiste: On Sat, 18 Apr 2009 11:24:14 -0400, Leandro Lucarella wrote: I've just found out[1] this[2]: The garbage collector is not guaranteed to run the destructor for

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Don, el 18 de abril a las 22:25 me escribiste: > >The current GC implementation don't call finalizers for data that's still > >reference when the program *ended* (this is allowed by the specs, so it's > >fine, the question is why it's allowed by the specs). > > I don't understand why D even has fi

Re: GC object finalization not guaranteed

2009-04-18 Thread Don
Leandro Lucarella wrote: Robert Jacques, el 18 de abril a las 11:56 me escribiste: On Sat, 18 Apr 2009 11:24:14 -0400, Leandro Lucarella wrote: I've just found out[1] this[2]: The garbage collector is not guaranteed to run the destructor for all unreferenced objects. Is there

Re: GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
Robert Jacques, el 18 de abril a las 11:56 me escribiste: > On Sat, 18 Apr 2009 11:24:14 -0400, Leandro Lucarella > wrote: > >I've just found out[1] this[2]: > > > > The garbage collector is not guaranteed to run the destructor for > > all unreferenced objects. > > > >Is there any reason

Re: GC object finalization not guaranteed

2009-04-18 Thread Robert Jacques
On Sat, 18 Apr 2009 11:24:14 -0400, Leandro Lucarella wrote: I've just found out[1] this[2]: The garbage collector is not guaranteed to run the destructor for all unreferenced objects. Is there any reason why D can't guarantee that all finalizers will be called, at least when

GC object finalization not guaranteed

2009-04-18 Thread Leandro Lucarella
I've just found out[1] this[2]: The garbage collector is not guaranteed to run the destructor for all unreferenced objects. Is there any reason why D can't guarantee that all finalizers will be called, at least when the program ends? [1] http://proj.llucax.com.ar/blog/dgc/blog/po