473,668 Members | 2,449 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

"HalcyonWil d" <Ha**********@g mail.com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.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:
"HalcyonWil d" <Ha**********@g mail.com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.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

"HalcyonWil d" <Ha**********@g mail.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.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:
"HalcyonWil d" <Ha**********@g mail.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.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
1394
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
11082
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 it is simple, self-
5
2346
by: Charles T. | last post by:
Hi, looking for advance article/books on garbage-collected allocation. thanks, Charles.
28
3166
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 this work be library based or language based and will it be based on that of managed C++? Then of course there are the finer technical questions raised (especially due to pointer abuse). Is a GC for C++ just a pipe dream or is there a lot of work...
3
384
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 garbage collection (in the first place , garbage will not be generated !! ) . Is it possible to have a compiler with such feature. Or if Its not a good idea (or may be this is an idiotic idea) please tell me why is it so ??
350
11711
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 one, and in what percentage of your projects is one used? I have never used one in personal or professional C++ programming. Am I a holdover to days gone by?
46
2169
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, and auto_ptrs, gurus suggest that may be better to use a reference-counted smart pointer, or a garbage-collector. But in which cases it is better to use one technique and in which cases another? IOW, which is the design criterion?
109
3913
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 losing ground. There is a simple explanation for this. Languages without automated garbage collection are getting out of fashion. The chance of running into all kinds of memory problems is gradually outweighing the performance penalty you have to
158
7798
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 discouraged due to some specific reason. If someone can give inputs on the same, it will be of great help. Regards, Pushpa
0
8459
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8889
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8790
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8652
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5677
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2782
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2017
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.