Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Garbage collection in C
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Gordon Burditt, post: 1672391"] Yes , I know that of course. But I was commenting on the fact I claim that any real implementation of garbage collection for C (the implementation NEED NOT be portable) has at least one of three (fatal) problems: (1) It never frees anything, in which case it can't be called garbage collection. (2) It frees stuff when it shouldn't. In particular, it doesn't deal properly with pointers stored in files (and read back and used later by the same invocation of the program) or encrypted pointers stored in files, or encrypted pointers stored in memory. (3) It uses excessive resources during garbage collection. (Yes, this is subjective, but I classify reading whole hundred-terabyte files looking for pointers that aren't there as excessive.) C already has (1). (2) is not an issue for at least 99.99% of real programs, but it does introduce problems doing something that ANSI C says is acceptable. (3) is likely caused by trying to fix (2). This is true if a number of things available from third-party libraries are substituted for GC: say, networking, graphics, database access, etc. I have grave doubts that it is possible to write a practical GC system for C that doesn't have at least one of the problems listed above. That business about allowing pointers in files makes it really hard. My standard for C + GC: take the ANSI C standard, and add a statement that a program may malloc() memory without freeing it, memory that no longer has any reference to it anywhere is freed automatically (eventually), putting off running out of resources. Anything that doesn't cause Undefined Behavior in plain ANSI C shouldn't cause it in C + GC. Perhaps it could require that the program: #include <stdlib.h> int main(void) { char *p; while (1) { p = malloc(1); } } shouldn't ever run out of memory. I'm not going to require that the IMPLEMENTATION of GC be written in portable C (the implementation of fopen() needn't be portable either). It won't help. Gordon L. Burditt [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Garbage collection in C
Top