Freeing of memory (garbage collection)

2008-12-08 Thread Dan W
A couple of questions: 1: Even though D has an automatic garbage collector, is one still allowed to free the memory of a malloced array manually (using free () ), to avoid pauses in the program? 2: One justification on the website for using automatic garbage collection is how "allocated memory wi

Re: Freeing of memory (garbage collection)

2008-12-08 Thread BCS
Reply to Dan, A couple of questions: 1: Even though D has an automatic garbage collector, is one still allowed to free the memory of a malloced array manually (using free () ), to avoid pauses in the program? Yes, in fact if you malloc memory you MUST free it. Only stuff like dynamic arrays

Re: Freeing of memory (garbage collection)

2008-12-09 Thread bearophile
Dan W: > 1: Even though D has an automatic garbage collector, is one still > allowed to free the memory of a malloced array manually (using free > () ), to avoid pauses in the program? Other people here will just answer your question. But remember that in D manual memory management is done only i

Re: Freeing of memory (garbage collection)

2008-12-09 Thread Daniel White
Thanks for that reply. I wonder if extending automatic garbage collection for malloced memory would be a good idea... > Only stuff like dynamic > arrays, AAs and new'ed stuff gets cleaned up by the GC. For the above types of allocating memory, is there a way to 'lock' a variable and say to D, "d

Re: Freeing of memory (garbage collection)

2008-12-09 Thread Steven Schveighoffer
"Daniel White" wrote > Thanks for that reply. I wonder if extending automatic garbage > collection for malloced memory would be a good idea... > >> Only stuff like dynamic >> arrays, AAs and new'ed stuff gets cleaned up by the GC. > > For the above types of allocating memory, is there a way to 'loc

Re: Freeing of memory (garbage collection)

2008-12-09 Thread Jarrett Billingsley
On Tue, Dec 9, 2008 at 9:16 AM, Daniel White <[EMAIL PROTECTED]> wrote: > Thanks for that reply. I wonder if extending automatic garbage > collection for malloced memory would be a good idea... That would be a bad idea. Then how would you do manual memory management in the few cases that absolute

Re: Freeing of memory (garbage collection)

2008-12-09 Thread Jarrett Billingsley
On Tue, Dec 9, 2008 at 9:42 AM, Jarrett Billingsley <[EMAIL PROTECTED]> wrote: > On Tue, Dec 9, 2008 at 9:16 AM, Daniel White <[EMAIL PROTECTED]> wrote: >> Thanks for that reply. I wonder if extending automatic garbage >> collection for malloced memory would be a good idea... > > That would be a ba

Re: Freeing of memory (garbage collection)

2008-12-09 Thread Daniel White
> That would be a bad idea. Then how would you do manual memory > management in the few cases that absolutely require it? Two ways. Either: a: being able to lock the variable so that the garbage collector can't touch it until you unlock it. b: Using a slightly different version of malloc (say '

Re: Freeing of memory (garbage collection)

2008-12-09 Thread Jarrett Billingsley
On Tue, Dec 9, 2008 at 11:08 AM, Daniel White <[EMAIL PROTECTED]> wrote: >> That would be a bad idea. Then how would you do manual memory >> management in the few cases that absolutely require it? > > Two ways. Either: > > a: being able to lock the variable so that the garbage collector > can't to

Re: Freeing of memory (garbage collection)

2008-12-09 Thread Daniel White
Jarrett Billingsley Wrote: > On Tue, Dec 9, 2008 at 11:08 AM, Daniel White <[EMAIL PROTECTED]> wrote: > >> That would be a bad idea. Then how would you do manual memory > >> management in the few cases that absolutely require it? > > > > Two ways. Either: > > > > a: being able to lock the variabl

Re: Freeing of memory (garbage collection)

2008-12-09 Thread Jarrett Billingsley
On Tue, Dec 9, 2008 at 2:53 PM, Daniel White <[EMAIL PROTECTED]> wrote: > Jarrett Billingsley Wrote: > >> On Tue, Dec 9, 2008 at 11:08 AM, Daniel White <[EMAIL PROTECTED]> wrote: >> >> That would be a bad idea. Then how would you do manual memory >> >> management in the few cases that absolutely r

Re: Freeing of memory (garbage collection)

2008-12-09 Thread Christopher Wright
Daniel White wrote: That would be a bad idea. Then how would you do manual memory management in the few cases that absolutely require it? Two ways. Either: a: being able to lock the variable so that the garbage collector can't touch it until you unlock it. If you have a reference to the mem

Re: Freeing of memory (garbage collection)

2008-12-09 Thread bearophile
Steven Schveighoffer: > One thing you can do, that nobody has mentioned yet, is delete memory that > you have allocated using the GC. Leaving the GC manage and free your memory is usually OK. Managing manually your memory allocated from the C heap is doable. But freeing manually and forcefully

Re: Freeing of memory (garbage collection)

2008-12-13 Thread Sergey Gromov
Tue, 9 Dec 2008 03:25:07 + (UTC), Dan W wrote: > 1: Even though D has an automatic garbage collector, is one still > allowed to free the memory of a malloced array manually (using free > () ), to avoid pauses in the program? Just to clarify. There are 3 types of allocation: 1. std.c.stdlib