Re: GC performance - GC fragility



Jolyon Smith wrote:
In article <47ab65dc$1@xxxxxxxxxxxxxxxxxxxxxx>, Andre Kaufmann says...

For example returning an object from a dll function. Who owns the object ? With a GC you don't have to care.

A GC might make you think you don't have to care but you almost certainly DO.

I think you know what I meant. Not who's accessing it, but freeing it.
There's IMHO only one rational solution in native languages - reference counting.

Passing an object to another thread. Besides concurrency you don't have to care about which thread owns the object.

Again, it's this sort of cavalier thinking that GC promotes that I find dangerous.

Well, it the option to permanently let the developer to think about how to get it right better ? Why should I do this as an expert ? And anyways I would make errors, even if I would be forced to think about it.

I rather would let the compiler create code to check in the debug version, if somethings has been coded wrong. E.g. .NET will raise an error if you use STA GUI objects from another thread.

The less people care, the less people think and the less people think the more mistakes they will make.

O.k. let's take a simple example:

Store an object (pointer) in 10 different lists, so that each list holds the same pointer to the same object.

Now remove the object pointer from one of these lists.
How do you track in a native language, when you have to delete the object easily ?


[...]

In native languages only one solution (for the problems above) comes to my mind: reference counting.

There is another: contracts and attention to detail.

Well one additional comes to my mind: Copying - as most functional based solutions / languages do. I don't know what you mean with contracts in this context.
Attention - why should I regularly pay for something what the compiler could do for me automatically. In C++ I have Smart Pointers, but anyway they are based internally on reference counting. In Delphi I have Interfaced Objects, they are based on reference counting too.
When I have to pass Dll boundaries I could use Interfaced Objects, but IMHO somewhat tedious using COM for passing simple objects.


In .NET it's quite straightforward to pass an object, even over dll boundaries - simply by returning it.

e.g:

function GetListCopy() : List<int>


Yes - a native language basis - native CTS - just could do the same, but IMHO only by using reference counting or by copying the objects to another languages heap.


Well, IMHO you get benefits, but I agree - you don't get them for free - you still have to care about memory management and GC generations.

[...]
Better to eat properly in the first place, imho.
:)

Yes, but I don't permanently want to eat - I would be going fat by doing this ;-).

Andre



.



Relevant Pages

  • Re: GC performance - GC fragility
    ... The benefit of a GC to any specific app is indeterminate and often not a ... Besides concurrency you don't have to care about which thread owns the object. ... In native languages only one solution comes to my mind: reference counting. ...
    (borland.public.delphi.non-technical)
  • Re: Conceptual, Logical, and Physical views of data
    ... As an aside, let me just relate that about 2 years ago, I had a lengthy discussion at work in which it was me vs. 2 guys with CS Ph.Ds, with them taking the position that there's no difference between a pointer and a foreign key. ... I don't care what some other developer's 'meaning' for it is as long as that meaning works in his application and doesn't screw up mine. ... I'm not interested in trying to prove it, but I suspect that if one took some of their pronouncements to heart, all logical database development would come to a permanent halt. ... However, if somebody else doesn't see it my way, good for them, and let them explain all the costs, short-term and long-term of their better approach (and better it may be in their particular case, especially if the boss and owners don't care about the long-term in which case I'd hope it was a commercial and not a government 'enterprise') to their boss or customer. ...
    (comp.databases.theory)
  • Re: pointer one past malloc.ed memory
    ... If you care to post some C code which exhibits the ... > For example pointer to a struct. ... No. Pointers are scalar but not integer types. ... is a signed integer type called ptrdiff_t, ...
    (comp.lang.c)
  • Re: marshall interface needed?
    ... don't need to know nor care that A uses B at all. ... and properly marshal A's pointer. ... A is registered as an MTA component, and expects to be called on an MTA ... internal implementation detail of A, of which you shouldn't know nor ...
    (microsoft.public.vc.language)