Hello,
I will not add any more to this discussion here, as I believe it is OT.
Anyway, just one hint:
Ancient_Hacker said:
Please explain exactly how garbage collection can ever work with C in
these cases: [...]
Now please explain how the memory allocated for p1 gets preserved, or
collected, at the proper times, as the case may be. Hint: velly velly
difficult to impossible.
I think this will work. lcc-win32 uses Boehm's garbage collector, cf.
http://www.hpl.hp.com/personal/Hans_Boehm/gc/
Notice that this GC is "conservative", that is, it will not free memory
until it is absolutely sure that it is unused. When in doubt, it will
rather keep the memory, so it will not break anything.
This results in some "interesting" facts:
(From
http://www.hpl.hp.com/personal/Hans_Boehm/gc/faq.html):
"Does this mean that the collector might leak memory?
In the short term yes. But it is unlikely, though not impossible, that
this will result in a leak that grows over time. Under normal
circumstances, short term, or one time leaks are a minor issue. Memory
leaks in explicitly managed programs are feared because they almost
always continue to grow over time.
[...]
If my heap uses 2 GB on a 32-bit machine, won't every other integer or
other random data be misinterpreted as a pointer by the collector?
Thus won't way too much memory be retained?
Maybe. Probably, if the collector is used purely conservatively, with
no pointer layout information (such as use of GC_MALLOC_ATOMIC)."
The most interesting part: This GC is not perfect (unlike Jacob wants us
make to believe), thus, chances are that you will end up with some
long-term memory leaks.
This website of Boehm is very interesting, and you can see the
advantages and the disadvantages of this GC; thus, you can decide if you
want to use it or not.
Anyway, as it clearly is not part of any "official" version of C (unlike
state by Jacob), I consider it off-topic. Thus, I will not answer on
this topic anymore here.
Regards,
Spiro.