473,408 Members | 2,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

garbage collection with digital mars compiler

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
8 1758
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

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
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

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

"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

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

"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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Marek S | last post by:
Does anybody use Digital Mars compiler to compile extension modules for Python on Windows? I tried but failed. Can you please post a little HOWTO. Thank you.
18
by: Agent Mulder | last post by:
Hi group, I am looking for the BEST C++ compiler that holds the 3f criterium: * free * flat * fast Free means that I am free to sell the software I write with it. Flat means that...
5
by: Charles T. | last post by:
Hi, looking for advance article/books on garbage-collected allocation. thanks, Charles.
28
by: Goalie_Ca | last post by:
I have been reading (or at least googling) about the potential addition of optional garbage collection to C++0x. There are numerous myths and whatnot with very little detailed information. Will...
3
by: onkar | last post by:
This idea might be vey crazy. But I hope to get answers to this .. from comp.lang.c If a compiler is designed such that it automatically adds a free() matching every malloc() then is it not a...
350
by: Lloyd Bonafide | last post by:
I followed a link to James Kanze's web site in another thread and was surprised to read this comment by a link to a GC: "I can't imagine writing C++ without it" How many of you c.l.c++'ers use...
46
by: Carlo Milanesi | last post by:
Hello, traditionally, in C++, dynamically allocated memory has been managed explicitly by calling "delete" in the application code. Now, in addition to the standard library strings, containers,...
109
by: jacob navia | last post by:
In an interviw with Dr Dobbs, Paul Jansen explains which languages are gaining in popularity and which not: <quote> DDJ: Which languages seem to be losing ground? PJ: C and C++ are definitely...
158
by: pushpakulkar | last post by:
Hi all, Is garbage collection possible in C++. It doesn't come as part of language support. Is there any specific reason for the same due to the way the language is designed. Or it is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.