As many people know, I think that garbage collection is a good
solution for many memory allocation problems.
I am aware however, that nothing is "the silver bullet", not
even the GC.
A recent article in slashdot http://developers.slashdot.org/artic.../11/17/0552247
proves that.
A C# application was leaking memory, and the application would
become slower and slower because the memory was getting full and the
system was swapping like mad until it just failed.
Why?
Because a list that should be destroyed wasn't being destroyed.
This is similar to another bug that Sun discovered in their
Java implementation. The list wasn't being destroyed because
SOMEWHERE there was a reference to that list, and the GC could
not destroy it.
It is interesting to note that this bug is as difficult to trace as
a missing free or similar bugs. It required a specialized tool
to find it (yes, there are specialized tools to solve GC memory
allocation problems as there are specialized tools to solve
non-gc memory allocation problems)
The lesson to be learned is that you have to be careful (when using the
GC) to
1) Set all pointers to unused memory to NULL.
2) Do NOT store pointers to GC memory in permanent structures if you
want that data to eventually be collected.
The above bug was that the list registered itself in a global
data structure and wasn't getting destroyed.
If the GC wouldn't have been there, the programmer would have freed
the memory, what would have closed the memory leak but left
a dangling pointer in the global data structure!
Not a better alternative.
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique http://www.cs.virginia.edu/~lcc-win32
Nov 18 '07
84 3555
cr88192 said:
"Richard Heathfield" <rj*@see.sig.in validwrote in message
<snip>
>So "some people" rather than "most people", yes?
some, or most, a difficult and not very solid argument...
one would then have to count to know one way or another.
You seem to have missed my point, which is only that "some" is a safe
claim, whereas "most" is not.
>>after all, if no one really wanted GC, then Java and C# would leave them out,
Since the only relevant language here in comp.lang.c is C, and since C doesn't have GC, we can deduce from your argument that no C programmer really wants GC. (That's the trouble with logic - it can bite you back.)
or, a much simpler argument:
I am a C programmer, and I use GC in C, thus, there exist C programmers
who use GC.
Indeed. Again, you seem to have missed my point, which is that your
argument was faulty. Had it not been, I would not have been able to turn
it back on itself.
if no C programmers wanted GC,
Undoubtedly some do. Undoubtedly others don't. Undoubtedly still others do
want it but only under certain conditions.
<snip>
so, to the first question, are people like me or you the majority?...
Who knows? It might be neither of us. I'd certainly be very surprised to
find myself in a majority in *any* area where I actually had a choice
about which side I was on. Almost certainly most people, if asked, will
want garbage collection, but equally certainly most of them will *think*
you are asking whether they are in favour of the folk that bring the big
lorry round once a week (or once a fortnight, in more primitive areas).
--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
In article <Hq************ *************** ***@bt.com>,
Richard Heathfield <rj*@see.sig.in validwrote:
>myself, many other people I talk to, ...
>So "some people" rather than "most people", yes?
Almost everything expressed here is an opinion, and it's not
unreasonable to have an opinion about what most people want.
>You don't speak for me, that's for sure.
I think it will be clear to most regular readers that whether one
speaks for Richard Heathfield is unrelated to whether one speaks for
"most people". And this is not intended to express a preference
either way.
-- Richard
--
"Considerat ion shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
In article <23************ *************** @saipan.com>, cr88192
<cr*****@hotmai l.comwrote on Monday 19 Nov 2007 4:44 pm:
>
"Richard Heathfield" <rj*@see.sig.in validwrote in message
news:Hq******** *************** *******@bt.com. ..
>Chris Dollin said:
<snip>
>>I am a hedgehog of very little brain, and as well as long words bothering me, I only have so much brain-power to give to my code; if I can give up a significant part of store-management worries to the language /at an acceptable price/, whizzo! I'm all for it, it leaves me free to attend to other, less automatable, parts of program design.
Sure, and I agree - but I remain unconvinced that it is available /at an acceptable price/.
so, which is more expensive?
GC, or OpenGL?...
<snip>
What may be "an acceptable price" in some situations may not be
acceptable in others. Obviously C is still used to some extent on the
Desktop and hence programmers for that domain might consider a
Standardised GC as helping to "close the gap" between C and it's
more "Desktop ubiquitous" cousins. Many Desktop programmers don't
want/like to "go the whole hog" and use massive platforms like Java
and .NET. At the same time, some of them may wish for some of the
conveniences of those languages Standardised in C.
On the other hand it looks more likely that a GC would be Standardised
for C++ sooner than for C, so such developers might want to consider
C++. It provides all the "heavy ammunition" that C has, and also most
of the higher level language constructs and facilities of platforms
like Java and .NET. What it lacks, of course, is a massive standardised
code library (like in Java), but Boost can ease matters here.
In article <iL************ *************** ***@bt.com>, Richard Heathfield
<rj*@see.sig.in validwrote on Monday 19 Nov 2007 5:00 pm:
cr88192 said:
<snip>
>if no C programmers wanted GC,
Undoubtedly some do. Undoubtedly others don't. Undoubtedly still
others do want it but only under certain conditions.
<snip>
>so, to the first question, are people like me or you the majority?...
Who knows? It might be neither of us. I'd certainly be very surprised
to find myself in a majority in *any* area where I actually had a
choice about which side I was on. Almost certainly most people, if
asked, will want garbage collection, but equally certainly most of
them will *think* you are asking whether they are in favour of the
folk that bring the big lorry round once a week (or once a fortnight,
in more primitive areas).
Funny. Around here it's every day, or rather night. Wonder which place
can go for a week without GC.
llothar <ll*****@web.de writes:
>You miss my point. Conservative GC is always "safe" since anything that even looks like a reference will prevent memory from being freed, but
Bullshit.
Not in context. Several message into a sub-thread I am not going to
keep repeating all the well-known problems that GCs have with hidden
pointers. Clipped out like this, the statement is false. I meant I
was not pointing out a safety issue since it does not natter if these
pointers are hidden or not.
Maybe you should at least read the README.txt of Boehms GC before
talking about Garbage Collection.
I am aware of these problems -- in fact I posted about them the last
time this topic came up here.
--
Ben. ri*****@cogsci. ed.ac.uk (Richard Tobin) writes:
In article <87************ @bsb.me.uk>,
Ben Bacarisse <be********@bsb .me.ukwrote:
>>You miss my point. Conservative GC is always "safe" since anything that even looks like a reference will prevent memory from being freed
In C, you do have to keep pointers as things that look like a
reference. You can memcpy() the bits of a pointer and shuffle them
up, wait a while, then unshuffle them and store them back in a
pointer. You can even print them out to a file. No GC is going to
handle that unaided.
Yes, I've been called out for that quote already. I should have said
that *in this case* (the problem of freeing a block containing GC
pointers) conservative GC is safe. I just wanted to make it clear I
was not pointing out a correctness problem, just one of late
collection.
--
Ben.
"santosh" <sa*********@gm ail.comwrote in message
news:fh******** **@registered.m otzarella.org.. .
In article <23************ *************** @saipan.com>, cr88192
<cr*****@hotmai l.comwrote on Monday 19 Nov 2007 4:44 pm:
>> "Richard Heathfield" <rj*@see.sig.in validwrote in message news:Hq******* *************** ********@bt.com ...
>>Chris Dollin said:
<snip>
I am a hedgehog of very little brain, and as well as long words bothering me, I only have so much brain-power to give to my code; if I can give up a significant part of store-management worries to the language /at an acceptable price/, whizzo! I'm all for it, it leaves me free to attend to other, less automatable, parts of program design.
Sure, and I agree - but I remain unconvinced that it is available /at an acceptable price/.
so, which is more expensive? GC, or OpenGL?...
<snip>
What may be "an acceptable price" in some situations may not be
acceptable in others. Obviously C is still used to some extent on the
Desktop and hence programmers for that domain might consider a
Standardised GC as helping to "close the gap" between C and it's
more "Desktop ubiquitous" cousins. Many Desktop programmers don't
want/like to "go the whole hog" and use massive platforms like Java
and .NET. At the same time, some of them may wish for some of the
conveniences of those languages Standardised in C.
it is my understanding that C and C++ still hold notable dominance on the
desktop as well (note, I lump then together here, because they are often
used in conjuction).
Java apps are a minority (actually, afaik, more people use Java on embedded
systems than on desktops).
C# has afaik as of yet not put a dent in much of anything much outside of
"MS and friends" land.
On the other hand it looks more likely that a GC would be Standardised
for C++ sooner than for C, so such developers might want to consider
C++. It provides all the "heavy ammunition" that C has, and also most
of the higher level language constructs and facilities of platforms
like Java and .NET. What it lacks, of course, is a massive standardised
code library (like in Java), but Boost can ease matters here.
yeah.
I actually still feel (oddly enough) that there are still some reasons for
preferring C over C++ (in general).
a few of these being:
my pre-existing codebase (many hundreds of kloc);
linkage issues (I mostly write "libraries" and not "frontends" , where using
C++ in libraries somewhat complicates the task of maintaining proper
linkage with C-based frontends);
various other subtle technical reasons...
C is also a simpler language (good and important news for those of us who
write code-processing tools, such as auto-header tools and compilers, ...).
so, a few misc reasons...
santosh wrote:
In article <iL************ *************** ***@bt.com>, Richard Heathfield
<rj*@see.sig.in validwrote on Monday 19 Nov 2007 5:00 pm:
>Who knows? It might be neither of us. I'd certainly be very surprised to find myself in a majority in *any* area where I actually had a choice about which side I was on. Almost certainly most people, if asked, will want garbage collection, but equally certainly most of them will *think* you are asking whether they are in favour of the folk that bring the big lorry round once a week (or once a fortnight, in more primitive areas).
Funny. Around here it's every day, or rather night. Wonder which place
can go for a week without GC.
Don't rub it in. Some UK councils have been trying to foist fortnightly
(biweekly) rubbish collection[1] on us...
Phil
[1] It's useful speaking British English here; for me there's no
ambiguity between "rubbish collection" and "garbage collection".
--
Philip Potter pgp <atdoc.ic.ac. uk
"Richard Tobin" <ri*****@cogsci .ed.ac.ukwrote in message
news:fh******** ***@pc-news.cogsci.ed. ac.uk...
In article <87************ @bsb.me.uk>,
Ben Bacarisse <be********@bsb .me.ukwrote:
>>You miss my point. Conservative GC is always "safe" since anything that even looks like a reference will prevent memory from being freed
In C, you do have to keep pointers as things that look like a
reference. You can memcpy() the bits of a pointer and shuffle them
up, wait a while, then unshuffle them and store them back in a
pointer. You can even print them out to a file. No GC is going to
handle that unaided.
worse yet, in my GC, all you have to do is put the pointer in unaligned
memory, and it will miss the reference.
this has not really been a problem in practice though...
(this makes the GC a lot faster, but leaves a few more cases where it can
potentially fail...).
in my case, I don't claim the GC is always "safe" or gueranteed to never
lose anything in various edge cases, only that it will generally work so
long as one doesn't try to do anything weird with it.
in my case, it is not a "malloc replacement" as such, rather, it is its own
API.
I use malloc where it makes sense, and GC where it makes sense, manually
freeing where it makes sense, and simply discarding memory where it makes
sense...
in my case, my practices generally seem to work...
-- Richard
--
"Considerat ion shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
>>>>"cr" == cr88192 <cr*****@hotmai l.comwrites:
crafter all, if no one really wanted GC, then Java and C# would
crleave them out, and things like Boehm, and the endless other
crcustom GC frameworks, would simply not be used.
Of course. *Someone* wants garbage collection. At times, even *I*
want garbage collection. But you cannot go from that statement, which
you have provided adequate evidence for, to your original claim that
*most* programmers want garbage collection without a whole lot more
evidence than you have thus far provided.
I see enough benefits to having a memory management scheme that's
completely deterministic and completely in the hands of the programmer
that I don't want to see it go away as an option. And (as has been
pointed out) the semantics of C make it very difficult to use a
garbage collector that's implemented as a library; I think the
effort's better spent elsewhere.
Charlton
--
Charlton Wilbur cw*****@chromat ico.net This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: James S |
last post by:
Hi,
Basically I've been fighting with this code for a few days now and
can't seem to work around this problem. Included is the output, the
program I use to get this error and the source code for my wrapper.
This is acually part of the project, libxmlconf on sourceforge. The
newest working version isn't there yet, and cvs is lagged by 6 hours
or so. So if you think you want to have a try at this I can tgz the
source for you. My...
|
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!
|
by: jacob navia |
last post by:
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?
|
by: Chris |
last post by:
Hi,
I think I'm having some problems here with garbage collection. Currently, I
have the following code:
public struct Event
{
public int timestamp;
|
by: C P |
last post by:
I'm coming from Delphi where I have to explicitly create and destroy
instances of objects. I've been working through a C#/ASP.NET book, and many
of the examples repeat the same SqlConnection, SqlDataAdapter etc. objects,
so I thought I'd create a class with a bunch of factory methods to create my
classes for me. But, I'm unclear about how garbage collection works, and if
it is safe to do this. It seems to compile, but am I asking for...
| |
by: jacob navia |
last post by:
Abstract
--------
Garbage collection is a method of managing memory by using a "collector"
library. Periodically, or triggered by an allocation request, the
collector looks for unused memory chunks and recycles them.
This memory allocation strategy has been adapted to C (and C++) by the
library written by Hans J Boehm and Alan J Demers.
Why a Garbage Collector?
-----------------------
|
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?
|
by: timothytoe |
last post by:
Microsoft fixed some garbage collection problems in IE6 almost a year
ago. I'm trying to figure out if many users of IE6 are unpatched and
still have the old buggier JScript in them.
I have a rather large ECMAScript app that is speedy enough in just
about every browser but IE6. Some people tell me just to forget IE6,
but it still seems to have significant share at www.w3schools.com. And
anecdotally, the place my brother works...
|
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
|
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...
|
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,...
| |
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,...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |