By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,499 Members | 1,751 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,499 IT Pros & Developers. It's quick & easy.

garbage collection with digital mars compiler

P: n/a
Hi,

I installed the free version(command line only) of the digital mars c++
compiler.

It said it features a garbage collection mechanism, but there was no
documentation. I figured out that you have to extend the class
mentioned in gc.h file. But it does not compile. Does the compiler
automatically extend the gc classes, while compiling.

I tested for the memory leak by running main in a very long loop and
commenting out the delete statements. It does fail and exits with
unpredictable results. Sometimes, an illegal memory access error and
sometimes, just writes out garbage to the command line and terminates
without any error.

Please tell me, in short, how to use GC in digital mars compiler. I
will try to work my way around. I dont know if I am on the right track.
Thanks.

Nov 22 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
HalcyonWild wrote:
Hi,

I installed the free version(command line only) of the digital mars c++
compiler.

It said it features a garbage collection mechanism, but there was no
documentation. I figured out that you have to extend the class
mentioned in gc.h file. But it does not compile. Does the compiler
automatically extend the gc classes, while compiling.

I tested for the memory leak by running main in a very long loop and
commenting out the delete statements. It does fail and exits with
unpredictable results. Sometimes, an illegal memory access error and
sometimes, just writes out garbage to the command line and terminates
without any error.

Please tell me, in short, how to use GC in digital mars compiler. I
will try to work my way around. I dont know if I am on the right track.
Thanks.


This question is off-topic here since it is concerned with a particular
vendor's garbage collector, but see the FAQ:

http://www.parashift.com/c++-faq-lit...html#faq-16.26

and following.

Cheers! --M

Nov 22 '05 #2

P: n/a

mlimber wrote:
HalcyonWild wrote:
Hi,

I installed the free version(command line only) of the digital mars c++
compiler.

It said it features a garbage collection mechanism, but there was no
documentation. I figured out that you have to extend the class
mentioned in gc.h file. But it does not compile. Does the compiler
automatically extend the gc classes, while compiling.

I tested for the memory leak by running main in a very long loop and
commenting out the delete statements. It does fail and exits with
unpredictable results. Sometimes, an illegal memory access error and
sometimes, just writes out garbage to the command line and terminates
without any error.

Please tell me, in short, how to use GC in digital mars compiler. I
will try to work my way around. I dont know if I am on the right track.
Thanks.
This question is off-topic here since it is concerned with a particular
vendor's garbage collector, but see the FAQ:


-----
Not offtopic really. It is not digitals garbage collector. It is the
Hans Boehm garbage collector which they bundle with their compiler.
-----

http://www.parashift.com/c++-faq-lit...html#faq-16.26


-----
Thanks for the link. I did go through the Boehms gc site *again*.
Cannot find the link which has source code samples, or anything that
has instructions to use the same. I went through the source file for
gc.h, and tried a few things, but no success.

If anyone has used this GC, please let me know how to use it.

Probably the subject line gave the wrong impression. It is a general
GC, and not particular to Digital mars , who just bundle it. Changing
the subject line.
-----

Nov 22 '05 #3

P: n/a
HalcyonWild wrote:
mlimber wrote:
HalcyonWild wrote:
Hi,

I installed the free version(command line only) of the digital mars c++
compiler.

It said it features a garbage collection mechanism, but there was no
documentation. I figured out that you have to extend the class
mentioned in gc.h file. But it does not compile. Does the compiler
automatically extend the gc classes, while compiling.

I tested for the memory leak by running main in a very long loop and
commenting out the delete statements. It does fail and exits with
unpredictable results. Sometimes, an illegal memory access error and
sometimes, just writes out garbage to the command line and terminates
without any error.

Please tell me, in short, how to use GC in digital mars compiler. I
will try to work my way around. I dont know if I am on the right track.
Thanks.


This question is off-topic here since it is concerned with a particular
vendor's garbage collector, but see the FAQ:


-----
Not offtopic really. It is not digitals garbage collector. It is the
Hans Boehm garbage collector which they bundle with their compiler.

[snip]

Still off-topic. According to
http://www.parashift.com/c++-faq-lit...t.html#faq-5.9, to be
on-topic "your question must be answerable by looking into the C++
language definition as determined by the ISO/ANSI C++ Standard
document, and by planned extensions and adjustments."

You, however, are concerned with a specific, non-standard algorithm
(and a particular implementation of it, at that). See that same FAQ for
some suggestions on better forums to post in.

Cheers! --M

Nov 22 '05 #4

P: n/a

mlimber wrote:
HalcyonWild wrote:
mlimber wrote:
HalcyonWild wrote:
> Hi,
>
> I installed the free version(command line only) of the digital mars c++
> compiler.
>
> It said it features a garbage collection mechanism, but there was no
> documentation. I figured out that you have to extend the class
> mentioned in gc.h file. But it does not compile. Does the compiler
> automatically extend the gc classes, while compiling.
>
> I tested for the memory leak by running main in a very long loop and
> commenting out the delete statements. It does fail and exits with
> unpredictable results. Sometimes, an illegal memory access error and
> sometimes, just writes out garbage to the command line and terminates
> without any error.
>
> Please tell me, in short, how to use GC in digital mars compiler. I
> will try to work my way around. I dont know if I am on the right track.
>
>
> Thanks.

This question is off-topic here since it is concerned with a particular
vendor's garbage collector, but see the FAQ:


-----
Not offtopic really. It is not digitals garbage collector. It is the
Hans Boehm garbage collector which they bundle with their compiler.

[snip]

Still off-topic. According to
http://www.parashift.com/c++-faq-lit...t.html#faq-5.9, to be
on-topic "your question must be answerable by looking into the C++
language definition as determined by the ISO/ANSI C++ Standard
document, and by planned extensions and adjustments."

You, however, are concerned with a specific, non-standard algorithm
(and a particular implementation of it, at that). See that same FAQ for
some suggestions on better forums to post in.

Cheers! --M


ahh well, I will look for that. any idea what that forum might be. BTW,
if anyone has any idea , please post, as I want to avoid multiposting,
posting the same thing to some other forum.
Thanks.

Nov 22 '05 #5

P: n/a

"HalcyonWild" <Ha**********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
I installed the free version(command line only) of the digital mars c++
compiler.

It said it features a garbage collection mechanism, but there was no
documentation.
I'd start with www.digitalmars.com/rtl/gc.html
I figured out that you have to extend the class
mentioned in gc.h file.


There isn't a class or a struct in \dm\include\gc.h. The API is described in
www.digitalmars.com/rtl/gcheader.txt. It has a C interface, not a C++ one,
so there won't be a need for class extending to use it.

The gc included with Digital Mars C/C++ is the Hans Boehm garbage collector.
For lots of details about it, see Hans' web site at
http://www.hpl.hp.com/personal/Hans_Boehm/gc/.

-Walter Bright
www.digitalmars.com C, C++, D programming language compilers
Nov 22 '05 #6

P: n/a

Walter Bright wrote:
"HalcyonWild" <Ha**********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
I installed the free version(command line only) of the digital mars c++
compiler.

It said it features a garbage collection mechanism, but there was no
documentation.


I'd start with www.digitalmars.com/rtl/gc.html
I figured out that you have to extend the class
mentioned in gc.h file.


There isn't a class or a struct in \dm\include\gc.h. The API is described in
www.digitalmars.com/rtl/gcheader.txt. It has a C interface, not a C++ one,
so there won't be a need for class extending to use it.

The gc included with Digital Mars C/C++ is the Hans Boehm garbage collector.
For lots of details about it, see Hans' web site at
http://www.hpl.hp.com/personal/Hans_Boehm/gc/.

-Walter Bright
www.digitalmars.com C, C++, D programming language compilers

Thanks a lot Walter. Great to hear from you.

I did visit those links. You mean to say, I must rather use gc_malloc
function to allocate memory and forget about it. No need to free the
memory. I will try that out.

I did see the gc.h file included in the zip install file. I might be
mistaken, but I saw the new operator implemented somewhere. Also, going
through it does seem to be a bit confusing (for me atleast, I dont have
much experience on C++).

A humble suggestion :) Please include some code samples too on the
Digital Mars site.

Nov 22 '05 #7

P: n/a

"HalcyonWild" <Ha**********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...

Thanks a lot Walter. Great to hear from you.

I did visit those links. You mean to say, I must rather use gc_malloc
function to allocate memory and forget about it. No need to free the
memory. I will try that out.

I did see the gc.h file included in the zip install file. I might be
mistaken, but I saw the new operator implemented somewhere. Also, going
through it does seem to be a bit confusing (for me atleast, I dont have
much experience on C++).

A humble suggestion :) Please include some code samples too on the
Digital Mars site.


I hate to say it, but using garbage collection with C++ is an advanced
technique. The language doesn't really support it, and so things get mucked
about under the hood to make it work. There are a lot of things to watch out
for, like interaction with APIs that also manage memory their own way. Once
you do get gc working with C++, though, it can be pretty nice.

Why not start out with a C++ like language designed to work with gc, like
the D programming language?

-Walter Bright
www.digitalmars.com C, C++, D programming language compilers
www.digitalmars.com/d/ the D programming language
Nov 23 '05 #8

P: n/a

Walter Bright wrote:
"HalcyonWild" <Ha**********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...

Thanks a lot Walter. Great to hear from you.

I did visit those links. You mean to say, I must rather use gc_malloc
function to allocate memory and forget about it. No need to free the
memory. I will try that out.

I did see the gc.h file included in the zip install file. I might be
mistaken, but I saw the new operator implemented somewhere. Also, going
through it does seem to be a bit confusing (for me atleast, I dont have
much experience on C++).

A humble suggestion :) Please include some code samples too on the
Digital Mars site.

I hate to say it, but using garbage collection with C++ is an advanced
technique. The language doesn't really support it, and so things get mucked
about under the hood to make it work. There are a lot of things to watch out
for, like interaction with APIs that also manage memory their own way. Once
you do get gc working with C++, though, it can be pretty nice.

Why not start out with a C++ like language designed to work with gc, like
the D programming language?



Sure. I have the D prog lang setup unzipped here, on my machine. I do
keep trying things on it, though I have not seen it or the digital mars
site since few months, because of workload at my job on Java. Also, the
D pages seem to have updated, or I found the right links for D this
time. I will try it further.

Also, my earlier suggestion again. More docs and code samples. Actually
, it is lack of enough samples and documents that keep me from trying
out "heavier" things on D, and exploring it further. There are
documents on the digital mars site, and also code snippets on the D
pages, but they are more like manuals rather than books, like the
"complete reference series" of mcgraw hill, or the "learning" series of
oreilly. More well commented code samples will suffice. Say like, more
complete code samples (working) on window manipuation, XML parsing, etc
in D.

It will take time for more books, and documents to come out in the
market, on D prog lang, IMHO, as it gains prevelance.

I also found out where I found the new operator overloaded. It is in
gc_cpp.h. I figured that gc_cpp would be the one to include, since I
was making a C++ program. It sure is complicated.

Thanks.

Nov 25 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.