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
Richard Heathfield <rj*@see.sig.in validwrites:
cr88192 said:
>must of us are in a land where we still want things like GC
By what authority do you speak for "must of us"?
I think that most of us want the memory allocator to magically do
the right thing in every instance without any effort on our part.
Some people call this magic wonderment "garbage collection".
--
"It wouldn't be a new C standard if it didn't give a
new meaning to the word `static'."
--Peter Seebach on C99
Ben Pfaff said:
Richard Heathfield <rj*@see.sig.in validwrites:
>cr88192 said:
>>must of us are in a land where we still want things like GC
By what authority do you speak for "must of us"?
I think that most of us want the memory allocator to magically do
the right thing in every instance without any effort on our part.
Again, who is "most of us"?
I don't want the MM subsystem to get creative. I want it to do exactly what
I tell it to do, exactly when I tell it to do it.
--
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 <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.
-- Richard
--
"Considerat ion shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
"Richard Heathfield" <rj*@see.sig.in validwrote in message
news:db******** *************@b t.com...
cr88192 said:
<snip>
>must of us are in a land where we still want things like GC
By what authority do you speak for "must of us"?
myself, many other people I talk to, ...
after all, if no one really wanted GC, then Java and C# would leave them
out, and things like Boehm, and the endless other custom GC frameworks,
would simply not be used.
but, of course, I don't speak for embedded developers really, mostly good
old desktop programmers...
GC by itself is not very expensive, but going over to something like Java or
C# is...
GC is worth the costs, but Java may not be.
and so on...
--
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
Richard Heathfield wrote:
cr88192 said:
<snip>
>must of us are in a land where we still want things like GC
By what authority do you speak for "must of us"?
I can't answer that. I /can/ say that /I/ want GC.
And I've got it [1]. I just don't see that it's the right tool /for C/,
certainly not to the point where it would be a mandatory part of
the Standard. I see no harm in an implementation providing GC /as
an option/, so long as it's an honest global GC, and the implementation
makes it clear that its a non-Standard /option/.
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.
[1] Because most of my work code nowadays is Java, and I've historically
used Lisp and Pop11 as well as implementing and then using languages
with GC.
--
Chris "one was pure functional" Dollin
Hewlett-Packard Limited registered office: Cain Road, Bracknell,
registered no: 690597 England Berks RG12 1HN
cr88192 said:
>
"Richard Heathfield" <rj*@see.sig.in validwrote in message
news:db******** *************@b t.com...
>cr88192 said:
<snip>
>>must of us are in a land where we still want things like GC
By what authority do you speak for "must of us"?
myself, many other people I talk to, ...
So "some people" rather than "most people", yes?
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.)
and things like Boehm, and the endless other custom GC frameworks,
would simply not be used.
but, of course, I don't speak for embedded developers really, mostly good
old desktop programmers...
You don't speak for me, that's for sure.
--
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
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/.
--
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
"Richard Heathfield" <rj*@see.sig.in validwrote in message
news:Hq******** *************** *******@bt.com. ..
cr88192 said:
>> "Richard Heathfield" <rj*@see.sig.in validwrote in message news:db******* **************@ bt.com...
>>cr88192 said:
<snip>
must of us are in a land where we still want things like GC
By what authority do you speak for "must of us"? myself, many other people I talk to, ...
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.
>
>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.
a similar point can be made about the OP, or for that matter, the existence
of this, and many similar threads.
if no C programmers wanted GC, then they would have no reason to post in
comp.lang.c or comp.std.c (unless of course, they were covert C# or Java
coders, which using myself as an example, I am not).
>and things like Boehm, and the endless other custom GC frameworks, would simply not be used.
but, of course, I don't speak for embedded developers really, mostly good old desktop programmers...
You don't speak for me, that's for sure.
possible.
so, to the first question, are people like me or you the majority?...
well, no one says that all C programmers have to use GC, or that
standardization is particularly needed, the fact that Boehm is de-facto is
probably good enough.
it is much like OpenGL. many people use it, but it is fine as a 3rd party
library...
--
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
"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?...
a GC, or at least of the conservative variety, only has a minor (and often
largely ignorable) impact on general coding practice.
with GL, often, a good portion of the app's operation ends up being focused
on the GL way of doing things, and the needed support machinery to use it
effectively is not exactly minor (GL has good and bad points).
yet, many still use GL, and so, for someone like me, it does not ask "that"
much to use GC as well...
now, what about DirectX?...
....
feature that may effect certain edge cases, of feature that almost totally
changes how you would structure an app?...
--
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
Richard Heathfield wrote:
Chris Dollin said:
>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/.
In my experience, for the kind of programming that I do, it's been available
since the 80s.
Tradeoffs differ among domains.
[I'm happy taking a performance hit from dynamic typing, too.]
--
Chris "polymorphi c" Dollin
Hewlett-Packard Limited registered office: Cain Road, Bracknell,
registered no: 690597 England Berks RG12 1HN 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: 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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
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...
| |