473,796 Members | 2,465 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Garbage collection in C

Tired of chasing free(tm) bugs?

Get serious about C and use lcc-win32. The garbage collector designed by Boehm is the best of its
class. Very simple:

#define malloc GC_malloc
#define free(a) (a=NULL)

NICE isn't it?

No more chasing free() bugs, no more this incredible tedious accounting where it is SO easy to miss
some pointer. Leave to the machine what the machine does best: the boring accounting work and
concentrate in your algorithm, the thing humans do best and where machines fail.

Garbage collection is not restricted to Java or C#. Lcc-win32 introduced it more than 2 years ago in
the context of a Windows C implementation. A DLL you link with your program, a header file more, and
MANY hours of debugging less.

And this code is portable, since Boehm's work runs in many Unices, workstations and many types of
machines.

Garbage collection means less headaches for you, and simpler programs to maintain and debug. The
amount of buggy code that is dedicated to manage the allocation system can be significant and it is
by experience one of the most difficults part to debug.

Scrap it!

http://www.cs.virginia.edu/~lcc-win32

jacob


Nov 13 '05
55 4180

"Alan Balmer" <al******@att.n et> wrote in message news:ve******** *************** *********@4ax.c om...
On Sun, 10 Aug 2003 10:34:43 +0200, "jacob navia"
<ja*********@ja cob.remcomp.fr> wrote:
Garbage collection is not restricted to Java or C#. Lcc-win32 introduced it more than 2 years ago inthe context of a Windows C implementation.


Where did you get the idea that garbage collection was invented two
years ago by Lcc-win32? Garbage collection was invented many years
before Java, C# or Windows existed.


Please Al, try to be fair:

1) I always said that the GC is the work of Mr Boehm and not mine.
I just adapted his work to lcc-win32 two years ago.
2) I did not invent garbage collection. This is ridiculous. The first
garbage collector I wrote was a mark/sweep for a lisp interpreter
in 1987. And GC was already an old hat back then.

Why you need this polemic?

Got an argument?

Explain it.

jacob

Nov 13 '05 #21
> #define malloc GC_malloc
#define free(a) (a=NULL)

NICE isn't it?

No more chasing free() bugs, no more this incredible tedious accounting where it is SO easy to miss some pointer. Leave to the machine what the machine does best: the boring accounting work and concentrate in your algorithm, the thing humans do best and where machines

fail.

I don't regard those arguments as valid arguments for GC. GC is one type of
resource management for memory. Since nothing else is offered, I assume that
you are proposing the same "incredible tedious accounting" for all _OTHER_
types of resource management, e.g. file handling.

There is a case for GC for some problems. This isn't it.

Stephen Howe
Nov 13 '05 #22
On Mon, 11 Aug 2003 18:30:56 +0200, "jacob navia"
<ja*********@ja cob.remcomp.fr> wrote:
"Alan Balmer" <al******@att.n et> wrote in message news:jp******** *************** *********@4ax.c om...
On Mon, 11 Aug 2003 02:22:38 +0200, "jacob navia"
<ja*********@ja cob.remcomp.fr> wrote:

and wrote, and wrote, and ...

I ignored the advertising the first time, but I am now very close to
filtering your messages as a continuing waste of my time and disk
space.


Please do so.


You've convinced me. Bye.

--
Al Balmer
Balmer Consulting
re************* ***********@att .net
Nov 13 '05 #23

"Stephen Howe" <SP************ *******@tnsofre s.com> wrote in message
news:3f******** *************** @reading.news.p ipex.net...
#define malloc GC_malloc
#define free(a) (a=NULL)

NICE isn't it?

No more chasing free() bugs, no more this incredible tedious accounting where it is SO easy to miss
some pointer. Leave to the machine what the machine does best: the boring

accounting work and
concentrate in your algorithm, the thing humans do best and where machines

fail.

I don't regard those arguments as valid arguments for GC. GC is one type of
resource management for memory. Since nothing else is offered, I assume that
you are proposing the same "incredible tedious accounting" for all _OTHER_
types of resource management, e.g. file handling.


Yes, I am afraid you are right. Garbage collecting files should be done by the
operating system, I suppose, if at all.

As you can see from the discussion above, the mere fact of introducing the gc
makes for so many flame wars that any other innovation would be very difficult

There is a case for GC for some problems. This isn't it.


Can you explain?
I am curious.

jacob


Nov 13 '05 #24
Alan Balmer wrote:
<ja*********@ja cob.remcomp.fr> wrote:
Garbage collection is not restricted to Java or C#. Lcc-win32
introduced it more than 2 years ago in the context of a Windows
C implementation.


Where did you get the idea that garbage collection was invented
two years ago by Lcc-win32? Garbage collection was invented
many years before Java, C# or Windows existed.


Or C, or even Pascal. I think it originated with Lisp.

--
Chuck F (cb********@yah oo.com) (cb********@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address!

Nov 13 '05 #25

"Stephen Howe" <SP************ *******@tnsofre s.com> wrote in message
news:3f******** *************** @reading.news.p ipex.net...
I don't regard those arguments as valid arguments for GC. GC is one type of resource management for memory. Since nothing else is offered, I assume that you are proposing the same "incredible tedious accounting" for all _OTHER_
types of resource management, e.g. file handling.


It's almost (almost) getting funny, the resistance you people are showing
against GC. Files are used totally differently. I have never seen anybody
including myself chasing an "fclose" bug, or closing an invalid file
pointer.
Nov 13 '05 #26
"jacob navia" <ja*********@ja cob.remcomp.fr> writes:
#define free(a) (a=NULL)


Bad idea. free()'s argument is not necessarily a modifiable
lvalue; e.g. free(malloc(1)) ;
--
"I've been on the wagon now for more than a decade. Not a single goto
in all that time. I just don't need them any more. I don't even use
break or continue now, except on social occasions of course. And I
don't get carried away." --Richard Heathfield
Nov 13 '05 #27
On Mon, 11 Aug 2003 20:11:34 +0200, in comp.lang.c , "jacob navia"
<ja*********@ja cob.remcomp.fr> wrote:
As you can see from the discussion above, the mere fact of introducing the gc
makes for so many flame wars that any other innovation would be very difficult


You miss the point entirely, and I begin to think you're trolling.
Nobody is against GC, merely against your promotion of a specific
implementation of it.
There is a case for GC for some problems. This isn't it.


Can you explain? I am curious.


As Dan Pop would say, "engage brain before posting"

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.c om/ms3/bchambless0/welcome_to_clc. html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 13 '05 #28
"jacob navia" <ja*********@ja cob.remcomp.fr> wrote:
"Alan Balmer" <al******@att.n et> wrote in message news:jp******** *************** *********@4ax.c om...
On Mon, 11 Aug 2003 02:22:38 +0200, "jacob navia"
<ja*********@ja cob.remcomp.fr> wrote:

and wrote, and wrote, and ...

I ignored the advertising the first time, but I am now very close to
filtering your messages as a continuing waste of my time and disk
space.


Please do so.

Your message is so constructive and full real arguments, that I think
it is better to ignore it.

comp.lang.c according to you,


I seriously considered using LCC as my C compiler for Windows. Yes,
seriously. But if this thread is a demonstration of its creator's love
for solid code, adherence to well-established good practice, and *sheer
bloody arrogance*, I'm now very seriously _re_-considering.

Congratulations . You just lost yourself a user. And a reader: *plonk*.

Richard
Nov 13 '05 #29
In article <bh**********@n ews4.tilbu1.nb. home.nl>, Serve La <ik@hier.nl> wrote:
It's almost (almost) getting funny, the resistance you people are showing
against GC. Files are used totally differently. I have never seen anybody
including myself chasing an "fclose" bug, or closing an invalid file
pointer.


I have.

And I'm not about to suggest that GC-style resource management would
have made the code work, or even made the bug less of a problem.
It definitely wouldn't've made it easier to find.

There are more things in heaven and earth,
Than are dreamt of in your philosophy.
dave
(For the curious: Another programmer's code was incorrectly using
freopen(...,std err) instead of fopen(...). (And then closing the file.
On every call.) This invoked the "Just Happens To Work As Expected"
sort of undefined behavior until I tried to read from a file around
calls to this code, and (after two days) I realized that when my code
opened the file it got the FILE structure that stderr pointed at (which
had been closed, and was therefore available for re-use), and the call
into the buggy code clobbered my FILE.)

--
Dave Vandervies dj******@csclub .uwaterloo.ca
[A]s K&R didn't quite say: "We have tried to eliminate the brevity of the first
edition. Patterns are not a big idea, and they are not well-served by a small
book". --Richard Heathfield in comp.lang.c
Nov 13 '05 #30

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

Similar topics

1
2338
by: Bob | last post by:
Are there any known applications out there used to test the performance of the .NET garbage collector over a long period of time? Basically I need an application that creates objects, uses them, and then throws them away and then monitors the garbage collection and store statistics on it, preferably in C#. I want to know what is the longest period of time that an application may lock up while garbage collection is processing. Thanks!
6
810
by: Ganesh | last post by:
Is there a utility by microsoft (or anyone) to force garbage collection in a process without have access to the process code. regards Ganesh
11
2737
by: Rick | last post by:
Hi, My question is.. if Lisp, a 40 year old language supports garbage collection, why didn't the authors of C++ choose garbage collection for this language? Are there fundamental reasons behind this? Is it because C is generally a 'low level' language and they didn't want garbage collection to creep into C++ and ruin everything? Just wondering :)
34
6435
by: Ville Voipio | last post by:
I would need to make some high-reliability software running on Linux in an embedded system. Performance (or lack of it) is not an issue, reliability is. The piece of software is rather simple, probably a few hundred lines of code in Python. There is a need to interact with network using the socket module, and then probably a need to do something hardware- related which will get its own driver written in C.
5
3614
by: Bob lazarchik | last post by:
Hello: We are considering developing a time critical system in C#. Our tool used in Semiconductor production and we need to be able to take meaurements at precise 10.0 ms intervals( 1000 measurement exactly 10 ms apart. In the future this may decrease to 5ms ). I am concerned that if garbage collection invokes during this time it may interfere with our measurement results. I have looked over the garbage collection mechanism and see no...
8
3047
by: mike2036 | last post by:
For some reason it appears that garbage collection is releasing an object that I'm still using. The object is declared in a module and instantiated within a class that is in turn instantiated by the mainline. The class that instantiated the object in question is definitely still in existence at the point garbage collection swoops in and yanks it out from under my processing. Is there a way to ensure an instantiated object cannot be freed...
28
3189
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...
56
3716
by: Johnny E. Jensen | last post by:
Hellow I'am not sure what to think about the Garbage Collector. I have a Class OutlookObject, It have two private variables. Private Microsoft.Office.Interop.Outlook.Application _Application = null; Private Microsoft.Office.Interop.Outlook.NameSpace _Namespace = null; The Constructor: public OutlookObject()
350
11907
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?
158
7909
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
9680
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
9528
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10230
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...
1
10174
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7548
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6788
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
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4118
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
3731
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.