473,811 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Garbage collection


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
pay for garbage collection.
<end quote>

lcc-win has been distributing a GC since 2004.

It really helps.
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Jun 27 '08
109 3981
George Peter Staplin <ge************ ***@xmission.co mwrites:
Some people are content with a few false references and thus the Boehm
GC works for them. I hope that their software isn't used for something
involving human lives, and that the allocations retained aren't
large.
Well I bet C is used in that area also. I just can hope it was
"tested" long and well enough to not contain any of the typical bugs
which plagues us C programmers.

Regards
Friedrich
--
Please remove just-for-news- to reply via e-mail.
Jun 27 '08 #101
Thanks for this interesting link. I did not know it, but looking over
it the suggestions seems to be better not using C++ at all. I can
agree witht that wholeheartly ;-)

Regards
Friedrich

--
Please remove just-for-news- to reply via e-mail.
Jun 27 '08 #102
George Peter Staplin <ge************ ***@xmission.co mwrites:
>
Unfortunately making an accurate GC for C would require compiler
support, and even then it would break in some cases due to the design of
C.
Yes it would change considerably instead of
"The programmers knows what he does" it would be
"The programmer knows what he does but I know better in the dynamic
memory allocation area"

that alone suggest it would be more complex ;-)

>
Some people are content with a few false references and thus the Boehm
GC works for them. I hope that their software isn't used for something
involving human lives, and that the allocations retained aren't
large.
I can not folow the arguments follow you mean the GC has bugs while
collecting things it is not supposed to collect or how do I have to
understand that.

This thread now has goten quite long. And many good and not so good
arguments were brought up. But seein it in a context of safety-critial
I think it's just one part (and I would think a smaller problem) to
have or not to have GC.

I for my part am nervouis with both alternatives, and I think
programmers should feel a bit uneasy about that area be it that they
support GC or beeing against it. There are so many other things which
can go wrong.

But let's see what might lead to use of C despite it's
shortcomings. It seem one thing C is well beyond nearly every other
language under the programming sun is that C compilers are now around
for more than 50 years. And the shortcomings have been surely
recogniced and they lead to a really big industry for "handling those
shortcomings". So I'd argue there's hardly a language whith more tools
for "getting around the early design decisions" than for every other
language.

Well nearly every other language does not need them. But are those
tools as mature? The questions still would be how one can judge that?
For C the "history of things implemented" is IMHO a hint on how "good
C really is" nearly all our "base tool" are based on C. Be it the
Operating Systems, Databases or any kind of Server. So I think one can
conclude that C is in the top of the maturity list. Probably this has
lead to use C in areas where there might be (theoretical or practical)
better alternatives. Howerver any time I read about safety-critical
software I have a somehow ungut feeling. But isn't somehow larger
while thinking of using GC with C or sticking to the manual memory
handling....

Regards
Friedrich

--
Please remove just-for-news- to reply via e-mail.
Jun 27 '08 #103

"Richard Heathfield" <rj*@see.sig.in validwrote in message
news:5a******** *************** *******@bt.com. ..
Eligiusz Narutowicz said:
....
>This is of course total rubbish. One can wrap malloc/free and log
mallocs and frees easily enough. You seem to be intent on making it into
some sort of impossible task. History states that it isn't. There are
plenty of reliable and long lasting C projects you know!

It's not just easy. It's almost trivial.
Sure. Have a look at 4.26 p.59 here as to why they restrict use of
malloc/free. This is nothing to do with how able the programmer is:

"Chris Thomasson" <cr*****@comcas t.netwrote in message
news:g-*************** *************** @comcast.com...
JSF C++ standards:
http://www.research.att.com/~bs/JSF-AV-rules.pdf
And I mentioned (if I can quote myself!) regarding avoid use of malloc():
Compare these two pieces of code:
(1)
char array[10000];

(2)
char *array;
array=malloc(10 000);
if (array==NULL) puts("YOU'RE DEAD"); /* what else can it do? */
That's must be plenty of code examples so complex (I'm thinking in terms of
recursive stuff) where: (a) you can't determine easily if it will run out of
memory, even ignoring fragmentation issues; (b) nor whether you can always
balance malloc() and free(); (c) if malloc() fails recovery is next to
impossible.

So it can only be almost trivial where the program itself is almost trivial
(in complexity and runtime unknowns rather than in size).

--
Bartc

Jun 27 '08 #104
Bartc wrote:
"Richard Heathfield" <rj*@see.sig.in validwrote in message
news:5a******** *************** *******@bt.com. ..
>Eligiusz Narutowicz said:
...
>>This is of course total rubbish. One can wrap malloc/free and log
mallocs and frees easily enough. You seem to be intent on making it into
some sort of impossible task. History states that it isn't. There are
plenty of reliable and long lasting C projects you know!
It's not just easy. It's almost trivial.

Sure. Have a look at 4.26 p.59 here as to why they restrict use of
malloc/free. This is nothing to do with how able the programmer is:

"Chris Thomasson" <cr*****@comcas t.netwrote in message
news:g-*************** *************** @comcast.com...
>JSF C++ standards:
http://www.research.att.com/~bs/JSF-AV-rules.pdf

And I mentioned (if I can quote myself!) regarding avoid use of malloc():
>Compare these two pieces of code:
(1)
char array[10000];

(2)
char *array;
array=malloc(1 0000);
if (array==NULL) puts("YOU'RE DEAD"); /* what else can it do? */

That's must be plenty of code examples so complex (I'm thinking in terms of
recursive stuff) where: (a) you can't determine easily if it will run out of
memory, even ignoring fragmentation issues; (b) nor whether you can always
balance malloc() and free(); (c) if malloc() fails recovery is next to
impossible.

So it can only be almost trivial where the program itself is almost trivial
(in complexity and runtime unknowns rather than in size).
For Mr Heathfield all is trivial... He doesn't even need a debugger most
of the time. Superman comes to him to receive lessons in programming.

Now, he could be a millionaire because all people that buy expensive
malloc debugging tools would switch to his trivial method and pay HIM
instead of all those expensive tools...
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Jun 27 '08 #105
I wrote:
(...)
With CBFalconer-code the question is "has cbfalconer.home .att.net
recently been outsourced to some kid in India?"

This is why GC is the best choice for safety-critical programs nowadays.
Clearly forgetting the ":-)" was unfortunate. Sorry about that.

--
Hallvard
Jun 27 '08 #106
jacob navia wrote:
>
For Mr Heathfield all is trivial... He doesn't even need a debugger most
of the time. Superman comes to him to receive lessons in programming.

Now, he could be a millionaire because all people that buy expensive
malloc debugging tools would switch to his trivial method and pay HIM
instead of all those expensive tools...
Na, I'll stick with the excellent and free tools my platform of choice
provides.
--
Ian Collins.
Jun 27 '08 #107
"Hallvard B Furuseth" <h.**********@u sit.uio.nowrote in message
news:hb******** ******@bombur.u io.no...
>I wrote:
>(...)
With CBFalconer-code the question is "has cbfalconer.home .att.net
recently been outsourced to some kid in India?"

This is why GC is the best choice for safety-critical programs nowadays.

Clearly forgetting the ":-)" was unfortunate. Sorry about that.
It would have clarified things somewhat ;-)

--
Stuart
Jun 27 '08 #108
Hallvard B Furuseth wrote, On 28/04/08 11:25:
I wrote:
>(...)
With CBFalconer-code the question is "has cbfalconer.home .att.net
recently been outsourced to some kid in India?"

This is why GC is the best choice for safety-critical programs nowadays.

Clearly forgetting the ":-)" was unfortunate. Sorry about that.
Hey, it happens.
--
Flash Gordon
Jun 27 '08 #109
"jacob navia" <ja***@nospam.c omwrote in message
news:fv******** **@aioe.org...
Bartc wrote:
[...]
>And I mentioned (if I can quote myself!) regarding avoid use of malloc():
>>Compare these two pieces of code:
(1)
char array[10000];

(2)
char *array;
array=malloc( 10000);
if (array==NULL) puts("YOU'RE DEAD"); /* what else can it do? */

That's must be plenty of code examples so complex (I'm thinking in terms
of
recursive stuff) where: (a) you can't determine easily if it will run out
of
memory, even ignoring fragmentation issues; (b) nor whether you can
always balance malloc() and free(); (c) if malloc() fails recovery is
next to impossible.

So it can only be almost trivial where the program itself is almost
trivial
(in complexity and runtime unknowns rather than in size).

For Mr Heathfield all is trivial... He doesn't even need a debugger most
of the time. Superman comes to him to receive lessons in programming.
[...]

There are "some" ways to "attempt" to handle resource errors. For instance,
when I used to program server applications I would always "attempt" to
handle an allocation error like:
void server_emergenc y_resource_shri nk(int force) {
/* reduce sizes of all existing caches */
/* reduce max buffer sizes */
/* reduce system settings */
/* reduce working set */
/* attempt to reset/shrink region allocators */
/* shutdown non-critical services */
/* check for timeout connections */

if (force) {
/* forcefully drop connections */
/* forcefully destroy cached connection info */
}

/* ect, ect... */
}
void server_emergenc y_resource_crit ical() {
/* we are screwed!!! :^o */
}
void* server_private_ allocate(size_t sz) {
void* ptr = malloc(sz);
if (! ptr) {
server_emergenc y_resource_shri nk(0);
if (! (ptr = malloc(sz))) {
server_emergenc y_resource_shri nk(1);
if (! (ptr = malloc(sz))) {
server_emergenc y_resource_crit ical();
return NULL;
}
}
}
return ptr;
}

Try to reduce program state after an allocation error, and try again... If
it still fails, try to handle gracefully, user prompt, whatever, try and
avoid crashing.

Jun 27 '08 #110

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

Similar topics

1
2340
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
2745
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
6439
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
3621
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
3052
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
3194
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
3726
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
11952
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
7921
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
10397
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
10410
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,...
0
10138
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
9214
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6897
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
5564
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
5700
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4353
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
3878
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.