www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Garbage Collection

reply James Dunne <jdunne4 bradley.edu> writes:
Can we have a way in Linux to not use the garbage collector at all?  I know in
Windows you have to write your own WinMain() function and explicitly turn on the
garbage collector.  Can we have some version flag that does this for Linux or
some other similar method?  I'd like to see what I can do with D without garbage
collection.  I know gc.disable() works, but I really don't want it to even start
up initially.

Also, what's the current status on DLLs (and Linux SOs) with D's garbage
collector?

Regards,
James Dunne
Dec 28 2004
next sibling parent "Nick Sabalausky" <z a.a> writes:
I'm very curious about that too.  Perhaps I'm wrong, but it seems to me that 
the ability to opt-out of using the GC would be very beneficial on 
low-power/embedded devices.

"James Dunne" <jdunne4 bradley.edu> wrote in message 
news:cqt2un$2ico$1 digitaldaemon.com...
 Can we have a way in Linux to not use the garbage collector at all?  I 
 know in
 Windows you have to write your own WinMain() function and explicitly turn 
 on the
 garbage collector.  Can we have some version flag that does this for Linux 
 or
 some other similar method?  I'd like to see what I can do with D without 
 garbage
 collection.  I know gc.disable() works, but I really don't want it to even 
 start
 up initially.

 Also, what's the current status on DLLs (and Linux SOs) with D's garbage
 collector?

 Regards,
 James Dunne 
Dec 28 2004
prev sibling parent reply "Walter" <newshound digitalmars.com> writes:
"James Dunne" <jdunne4 bradley.edu> wrote in message
news:cqt2un$2ico$1 digitaldaemon.com...
 Can we have a way in Linux to not use the garbage collector at all?  I
know in
 Windows you have to write your own WinMain() function and explicitly turn
on the
 garbage collector.  Can we have some version flag that does this for Linux
or
 some other similar method?  I'd like to see what I can do with D without
garbage
 collection.  I know gc.disable() works, but I really don't want it to even
start
 up initially.
It's all controlled by the library. Full library source is included, and you can remove the gc by simply deleting it from dmain2.d and rebuilding phobos.
 Also, what's the current status on DLLs (and Linux SOs) with D's garbage
 collector?
Same as always !
Dec 29 2004
parent reply James Dunne <jdunne4 bradley.edu> writes:
It's all controlled by the library. Full library source is included, and you
can remove the gc by simply deleting it from dmain2.d and rebuilding phobos.
Then how do you free memory allocated with new since there's no delete keyword? Do I have to go with C's malloc and free? Or just write my own memory management *shudders*? Regards, James Dunne
Dec 29 2004
next sibling parent "Simon Buchan" <talk n.g> writes:
On Thu, 30 Dec 2004 06:55:32 +0000 (UTC), James Dunne <jdunne4 bradley.edu>
wrote:

 It's all controlled by the library. Full library source is included, and you
 can remove the gc by simply deleting it from dmain2.d and rebuilding phobos.
Then how do you free memory allocated with new since there's no delete keyword? Do I have to go with C's malloc and free? Or just write my own memory management *shudders*? Regards, James Dunne
Since there's no GC, I expect you wouldn't be able to use new (runtime exception?) P.S. I thought there was a delete keyword? Am I just stupid?
Dec 29 2004
prev sibling parent reply "Walter" <newshound digitalmars.com> writes:
"James Dunne" <jdunne4 bradley.edu> wrote in message
news:cr08p4$2na4$1 digitaldaemon.com...
It's all controlled by the library. Full library source is included, and
you
can remove the gc by simply deleting it from dmain2.d and rebuilding
phobos.

 Then how do you free memory allocated with new since there's no delete
keyword?
 Do I have to go with C's malloc and free?  Or just write my own memory
 management *shudders*?
There is a delete keyword! And yes, if you don't wish to use D's automatic memory management code, you'll need to manually manage it yourself. Using C's malloc/free is one way to do it.
Dec 30 2004
parent reply James Dunne <jdunne4 bradley.edu> writes:
In article <cr0i8v$5v$1 digitaldaemon.com>, Walter says...
"James Dunne" <jdunne4 bradley.edu> wrote in message
news:cr08p4$2na4$1 digitaldaemon.com...
It's all controlled by the library. Full library source is included, and
you
can remove the gc by simply deleting it from dmain2.d and rebuilding
phobos.

 Then how do you free memory allocated with new since there's no delete
keyword?
 Do I have to go with C's malloc and free?  Or just write my own memory
 management *shudders*?
There is a delete keyword! And yes, if you don't wish to use D's automatic memory management code, you'll need to manually manage it yourself. Using C's malloc/free is one way to do it.
Can I override the default behaviour of new/delete to use my own memory management? :):) If so, how and where? Thanks for the info! Regards, James Dunne
Jan 02 2005
next sibling parent reply James Dunne <jdunne4 bradley.edu> writes:
This just occurred to me... Can we have two memory-management targets for D?
One garbage collected (default), and the other manually managed with new/delete
(compiler switch)?  I'm sure you've got some nice C++ memory management code
lying around ;)  I also know you've got enough on your plate with this language
to feed for a few years, so I'm just throwing in my $0.02.

In article <cra8mt$pge$1 digitaldaemon.com>, James Dunne says...
In article <cr0i8v$5v$1 digitaldaemon.com>, Walter says...
"James Dunne" <jdunne4 bradley.edu> wrote in message
news:cr08p4$2na4$1 digitaldaemon.com...
It's all controlled by the library. Full library source is included, and
you
can remove the gc by simply deleting it from dmain2.d and rebuilding
phobos.

 Then how do you free memory allocated with new since there's no delete
keyword?
 Do I have to go with C's malloc and free?  Or just write my own memory
 management *shudders*?
There is a delete keyword! And yes, if you don't wish to use D's automatic memory management code, you'll need to manually manage it yourself. Using C's malloc/free is one way to do it.
Can I override the default behaviour of new/delete to use my own memory management? :):) If so, how and where? Thanks for the info! Regards, James Dunne
Jan 02 2005
parent "Walter" <newshound digitalmars.com> writes:
"James Dunne" <jdunne4 bradley.edu> wrote in message
news:cra9hh$qe0$1 digitaldaemon.com...
 This just occurred to me... Can we have two memory-management targets for
D?
 One garbage collected (default), and the other manually managed with
new/delete
 (compiler switch)?  I'm sure you've got some nice C++ memory management
code
 lying around ;)  I also know you've got enough on your plate with this
language
 to feed for a few years, so I'm just throwing in my $0.02.
You can override new/delete on a per-class basis.
Jan 02 2005
prev sibling parent reply "Walter" <newshound digitalmars.com> writes:
"James Dunne" <jdunne4 bradley.edu> wrote in message
news:cra8mt$pge$1 digitaldaemon.com...
 Can I override the default behaviour of new/delete to use my own memory
 management? :):)  If so, how and where?  Thanks for the info!
Replace the gc code in the library with your own. All the source is provided!
Jan 02 2005
parent "Simon Buchan" <not a.valid.address.com> writes:
On Sun, 2 Jan 2005 22:54:36 -0800, Walter <newshound digitalmars.com> wrote:

 "James Dunne" <jdunne4 bradley.edu> wrote in message
 news:cra8mt$pge$1 digitaldaemon.com...
 Can I override the default behaviour of new/delete to use my own memory
 management? :):)  If so, how and where?  Thanks for the info!
Replace the gc code in the library with your own. All the source is provided!
Hmm, these two responses by Walter seem to be the wrong way round...
Jan 03 2005