473,508 Members | 4,753 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3069
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
437
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
1766
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
2168
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
4762
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
3772
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
1529
by: ajayraj | last post by:
Can anybody say, from where i can get the content related to Boehm's garbage collector.
11
1391
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
2016
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
1819
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
4078
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
7228
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
7128
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7332
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
7393
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...
1
7058
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...
0
7502
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...
1
5057
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...
0
1565
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 ...
0
426
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.