473,390 Members | 953 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,390 software developers and data experts.

Boehm's garbage collector: beginner's questions

Dear sirs,

I am trying to learn how to use Boehm's garbage collector:
http://www.hpl.hp.com/personal/Hans_Boehm/gc/ on a Linux machine. I am
a beginner, and I find its documentation inadequate. I have followed
all instructions for installation, yet I still have the following
questions.

1) The instruction said to include the header file, and link to the
library file. I was wondering if I am doing it correctly in my
makefile:

-bash-2.05b$ more makefile
queries: queries.cpp queries.h /new/usr2/xxx/gc/include/gc.h
g++ -g -o3 queries.cpp /new/usr2/xxx/gc/lib/libgc.a -o
queries

I also include the gc.h file in my source.

2) The instruction said specifically to run "make c++" after a regular
make. I get the following error message, while the regular make and
make install works. I am using c++, so will this cause a problem?

-bash-2.05b$ make c++
make: *** No rule to make target `c++'. Stop.

3) I am using STL for most of my complex datasets. Does STL work at
all with Boehm? If it does, does it work automatically, or do I need
to specify some special options. What will happen if I use the
following defines:

#define malloc(n) GC_malloc(n)
#define calloc(m,n) GC_malloc((m)*(n))

Other than STL, I use my own codes for the rest of the stuff, so I am
not so worried.

4) In C++ do I include gc.h or do I use a different file?

5) Is there a gentler introduction to Boehm with examples that I can
use?

Thank you very much,

Joe
Jul 22 '05 #1
6 3052
Atip Asvanund wrote:
Dear sirs,
FYI, it's conventional to omit greetings and valedictories on usenet.
I am trying to learn how to use Boehm's garbage collector:
http://www.hpl.hp.com/personal/Hans_Boehm/gc/ on a Linux machine. I am
a beginner, and I find its documentation inadequate. I have followed
all instructions for installation, yet I still have the following
questions.
Is there a newsgroup, mailing list, faq, etc., listed on that site?
Your enquiry is off-topic for comp.lang.c++ - see the welcome message
at http://www.slack.net/~shiva/welcome.txt
1) The instruction said to include the header file, and link to the
library file. I was wondering if I am doing it correctly in my
makefile:

-bash-2.05b$ more makefile
queries: queries.cpp queries.h /new/usr2/xxx/gc/include/gc.h
g++ -g -o3 queries.cpp /new/usr2/xxx/gc/lib/libgc.a -o
It is not necessary to list gc.h as a prerequisite of queries, unless
you are going to edit that file.

A correct and idiomatic makefile might go something like this (and if
its filename is Makefile, with a capital 'M', you won't need to specify
the filename when you make).

CXX=g++
CPPFLAGS=-idirafter /new/usr2/xxx/gc/include
CXXFLAGS=-g -o3
LDFLAGS=-L /new/usr2/xxx/lib
LDLIBS=-lgc

all: queries

queries: queries.o
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)

queries.o: queries.cpp queries.h
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
queries
I don't see what this line was for.
I also include the gc.h file in my source.
This will be "#include <gc.h>" now.
2) The instruction said specifically to run "make c++" after a regular
make. I get the following error message, while the regular make and
make install works. I am using c++, so will this cause a problem?

-bash-2.05b$ make c++
make: *** No rule to make target `c++'. Stop.
Oh! Well, there must have been a makefile provided with the
distribution, or maybe some instructions for adding a target
called 'c++' to your own makefiles. I don't know, sorry.
3) I am using STL for most of my complex datasets. Does STL work at
all with Boehm? If it does, does it work automatically, or do I need
to specify some special options. What will happen if I use the
following defines:

#define malloc(n) GC_malloc(n)
#define calloc(m,n) GC_malloc((m)*(n))

Other than STL, I use my own codes for the rest of the stuff, so I am
not so worried.
By default the standard containers use the std::allocator which uses new
and delete. You may have to provide a custom allocator. (Ouch).
4) In C++ do I include gc.h or do I use a different file?
Some header files are written to be 'bilingual', but not all.
5) Is there a gentler introduction to Boehm with examples that I can
use?


Sorry, no idea.

--
Regards,
Buster.
Jul 22 '05 #2
Atip Asvanund wrote:
Dear sirs,
FYI, it's conventional to omit greetings and valedictories on usenet.
I am trying to learn how to use Boehm's garbage collector:
http://www.hpl.hp.com/personal/Hans_Boehm/gc/ on a Linux machine. I am
a beginner, and I find its documentation inadequate. I have followed
all instructions for installation, yet I still have the following
questions.
Is there a newsgroup, mailing list, faq, etc., listed on that site?
Your enquiry is off-topic for comp.lang.c++ - see the welcome message
at http://www.slack.net/~shiva/welcome.txt
1) The instruction said to include the header file, and link to the
library file. I was wondering if I am doing it correctly in my
makefile:

-bash-2.05b$ more makefile
queries: queries.cpp queries.h /new/usr2/xxx/gc/include/gc.h
g++ -g -o3 queries.cpp /new/usr2/xxx/gc/lib/libgc.a -o
It is not necessary to list gc.h as a prerequisite of queries, unless
you are going to edit that file.

A correct and idiomatic makefile might go something like this (and if
its filename is Makefile, with a capital 'M', you won't need to specify
the filename when you make).

CXX=g++
CPPFLAGS=-idirafter /new/usr2/xxx/gc/include
CXXFLAGS=-g -o3
LDFLAGS=-L /new/usr2/xxx/lib
LDLIBS=-lgc

all: queries

queries: queries.o
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)

queries.o: queries.cpp queries.h
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
queries
I don't see what this line was for.
I also include the gc.h file in my source.
This will be "#include <gc.h>" now.
2) The instruction said specifically to run "make c++" after a regular
make. I get the following error message, while the regular make and
make install works. I am using c++, so will this cause a problem?

-bash-2.05b$ make c++
make: *** No rule to make target `c++'. Stop.
Oh! Well, there must have been a makefile provided with the
distribution, or maybe some instructions for adding a target
called 'c++' to your own makefiles. I don't know, sorry.
3) I am using STL for most of my complex datasets. Does STL work at
all with Boehm? If it does, does it work automatically, or do I need
to specify some special options. What will happen if I use the
following defines:

#define malloc(n) GC_malloc(n)
#define calloc(m,n) GC_malloc((m)*(n))

Other than STL, I use my own codes for the rest of the stuff, so I am
not so worried.
By default the standard containers use the std::allocator which uses new
and delete. You may have to provide a custom allocator. (Ouch).
4) In C++ do I include gc.h or do I use a different file?
Some header files are written to be 'bilingual', but not all.
5) Is there a gentler introduction to Boehm with examples that I can
use?


Sorry, no idea.

--
Regards,
Buster.
Jul 22 '05 #3
Atip Asvanund wrote:

#define malloc(n) GC_malloc(n)
#define calloc(m,n) GC_malloc((m)*(n))


Several possible problems with this.

First, what if malloc and/or calloc is already #defined? You'd better
#undef them first.

Second, unless GC_malloc() zeros out the buffer it returns, you are
changing the semantics of calloc().

Third, you shouldn't use malloc(), calloc() and friends at all in C++
(unless you have a very good reason, which is rare). They don't do
proper initialization and destruction of objects.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Jul 22 '05 #4
Atip Asvanund wrote:

#define malloc(n) GC_malloc(n)
#define calloc(m,n) GC_malloc((m)*(n))


Several possible problems with this.

First, what if malloc and/or calloc is already #defined? You'd better
#undef them first.

Second, unless GC_malloc() zeros out the buffer it returns, you are
changing the semantics of calloc().

Third, you shouldn't use malloc(), calloc() and friends at all in C++
(unless you have a very good reason, which is rare). They don't do
proper initialization and destruction of objects.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Jul 22 '05 #5
I have not used Boehms garbage collector yet.
But I do know that in the March 2003 issue of
C/C++ Users Journal, there was an article
about Boehms garbage collector, and how to use it.

If you are not aware of this, then it might be
profitable for you to read it from local library.

Jul 22 '05 #6
I have not used Boehms garbage collector yet.
But I do know that in the March 2003 issue of
C/C++ Users Journal, there was an article
about Boehms garbage collector, and how to use it.

If you are not aware of this, then it might be
profitable for you to read it from local library.

Jul 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Atip Asvanund | last post by:
Dear sirs, I am trying to learn how to use Boehm's garbage collector: http://www.hpl.hp.com/personal/Hans_Boehm/gc/ on a Linux machine. I am a beginner, and I find its documentation inadequate....
8
by: HalcyonWild | last post by:
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...
18
by: Larry Herbinaux | last post by:
I'm having issues with garbage collection with my long-standing service process. If you could review and point me in the right direction it would be of great help. If there are any helpful...
5
by: R. MacDonald | last post by:
Hello, all, I am currently working on a .Net (VB) application that invokes routines in unmanaged (Fortran) DLLs. The unmanaged routines then communicate with the .Net application by means of a...
13
by: Mingnan G. | last post by:
Hello everyone. I have written a garbage collector for standard C++ application. It has following main features. 1) Deterministic Finalization Providing deterministic finalization, the system...
2
by: ajayraj | last post by:
Can anybody say, from where i can get the content related to Boehm's garbage collector.
11
by: xicloid | last post by:
I'm trying to write a program that saves numbers without any duplications. I was thinking I could start by storing the first number in an array with size one, and if the next number is not in the...
5
by: malkarouri | last post by:
Hi everyone, Is it possible to write a Python extension that uses the Boehm garbage collector? I have a C library written that makes use of boehm-gc for memory management. To use that, I have...
3
by: Razii | last post by:
On Mon, 14 Apr 2008 00:43:31 -0700 (PDT), James Kanze <james.kanze@gmail.comwrote: Doesn't look that simple to me. I downloaded gc version 6.7 and 6.8. nmake nodebug=1 gc.mak ...
1
by: monalikolhe | last post by:
Hey Guys, I am new to this programming stuff, but i want to try using Hans Boem Garbage Collector (HBGC) as my assignment. I dont know which Compiler to use for it and how to use? Please Help
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.