Live data from Hacker News

Reference count, don't garbage collect

kevinlawler.com

171–180 of 415 posts

Re: Reference count, don't garbage collect

#171

Earlier quoted context omitted.

> P&L research What’s P&L? > Java's verbose semantics Does Java have verbose semantics? I think Java’s semantics are pretty neat and concise. Where’s the verbosity?

Not OP, but someone who has gotten paid to write Java for several years. I would say that isn't that Java's semantics are that verbose, it's that the way Java is traditionally written, with every line actually 3 lines on your screen of public function makeItalicTextBox(String actualTextIWantToBeItalic) { ItalicTextBox itb = italicTextBoxFactoryGenerator.GenerateFactory().buildItalicTextBox(actualTextIWantToBeItalic);…

This is one of the reasons I left Java after 30 years. For those that wonder my day to day is now python and typescript.

Re: Reference count, don't garbage collect

#173

This debate has gone round and round for decades. There are no hard lines; this is about performance tradeoffs, and always will be. Perhaps the biggest misconception about reference counting is that people believe it avoids GC pauses. That's not true. Essentially, whereas tracing GC has pauses while tracing live data, reference counting has pauses while tracing garbage. Reference counting is really just another kind…

For a unifying term I prefer Automatic Memory Management. One reason is that GC is already universally used to mean only tracing garbage collection, and trying to defend its wider meaning is a pointless uphill battle. Another is that is suits the job much better, because not every AMM technique works by producing garbage then collecting it, you know.

What are these other techniques and what can a technically-literate newcomer like myself read to get acquainted?

Re: Reference count, don't garbage collect

#174
post #143

Earlier quoted context omitted.

How do you collect cycles without a pause?

There are solutions to this one. Real time garbage collectors are a thing. You just might not be able to collect the cycle in one GC run. Or you can do what Erlang does: Erlang has neither mutation nor laziness, so you can't create cycles. The GC also lays out object in topological order in memory, so that you can detect garbage without tracing every life object.

Where can I read about Erlang’s magic?

Re: Reference count, don't garbage collect

#175

Earlier quoted context omitted.

How do you collect cycles without a pause?

I'm gonna take a guess they dedicate a core to GC (or something along these lines).

That's not enough. Imagine a circular linked list. GC looks at an outside pointer to item A in it. Now another thread removes A from the list and moves the outside pointer to the next item. After that, GC would see all items in the list not referenced by anything (apart from the cycle).

Re: Reference count, don't garbage collect

#176

Earlier quoted context omitted.

I'm gonna take a guess they dedicate a core to GC (or something along these lines).

That's not enough. Imagine a circular linked list. GC looks at an outside pointer to item A in it. Now another thread removes A from the list and moves the outside pointer to the next item. After that, GC would see all items in the list not referenced by anything (apart from the cycle).

Yeah, I didn't say it was sufficient. I just said it's probably one of the things they do.

Re: Reference count, don't garbage collect

#177
post #143

Earlier quoted context omitted.

How do you collect cycles without a pause?

There are solutions to this one. Real time garbage collectors are a thing. You just might not be able to collect the cycle in one GC run. Or you can do what Erlang does: Erlang has neither mutation nor laziness, so you can't create cycles. The GC also lays out object in topological order in memory, so that you can detect garbage without tracing every life object.

The comment claimed "There are zero GC pauses." Tbh, it's not clear how to interpret that. But real time simply means the pauses are guaranteed not to cross the realtime response budget. You still need to schedule the collection while the mutator is paused.

Re: Reference count, don't garbage collect

#180
post #143

Earlier quoted context omitted.

There are solutions to this one. Real time garbage collectors are a thing. You just might not be able to collect the cycle in one GC run. Or you can do what Erlang does: Erlang has neither mutation nor laziness, so you can't create cycles. The GC also lays out object in topological order in memory, so that you can detect garbage without tracing every life object.

Where can I read about Erlang’s magic?

Google suggests https://stackoverflow.com/questions/10221907/garbage-collect...
Post reply on HN