<div dir="ltr">On 29 May 2013 03:27, Paulo Pinto <span dir="ltr"><<a href="mailto:pjmlp@progtools.org" target="_blank">pjmlp@progtools.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Am 28.05.2013 15:33, schrieb Steven Schveighoffer:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">
On Sat, 25 May 2013 01:52:10 -0400, Manu <<a href="mailto:turkeyman@gmail.com" target="_blank">turkeyman@gmail.com</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
What does ObjC do? It seems to work okay on embedded hardware<br>
(although not<br>
particularly memory-constrained hardware).<br>
Didn't ObjC recently reject GC in favour of refcounting?<br>
</blockquote>
<br>
Having used ObjC for the last year or so working on iOS, it is a very<br>
nice memory management model.<br>
<br>
Essentially, all objects (and only objects) are ref-counted<br>
automatically by the compiler.  In code, whenever you assign or pass a<br>
pointer to an object, the compiler automatically inserts retains and<br>
releases extremely conservatively.<br>
<br>
Then, the optimizer comes along and factors out extra retains and<br>
releases, if it can prove they are necessary.<br>
<br>
What I really like about this is, unlike a library-based solution where<br>
every assignment to a 'smart pointer' incurs a release/retain, the<br>
compiler knows what this means and will factor them out, removing almost<br>
all of them.  It's as if you inserted the retains and releases in the<br>
most optimized way possible, and it's all for free.<br>
<br>
Also, I believe the compiler is then free to reorder retains and<br>
releases since it understands how they work.  Of course, a<br>
retain/release is an atomic operation, and requires memory barriers, so<br>
the CPU/cache cannot reorder, but the compiler still can.<br></div>
...<br>
</blockquote>
<br>
I imagine Microsoft also does a similar thing with their C++/CX language extensions (WinRT handles).<br>
</blockquote></div><br></div><div class="gmail_extra" style>Yeah certainly. It's ref counted, not garbage collected. And Android's V8 uses a "<a href="http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Generational_GC_.28ephemeral_GC.29" title="Garbage collection (computer science)" style="font-size:13px;text-decoration:none;color:rgb(11,0,128);background-image:none;font-family:sans-serif;line-height:19.1875px">generational</a><span style="font-size:13px;color:rgb(0,0,0);font-family:sans-serif;line-height:19.1875px"> </span><a href="http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Stop-the-world_vs._incremental_vs._concurrent" title="Garbage collection (computer science)" style="font-size:13px;text-decoration:none;color:rgb(11,0,128);background-image:none;font-family:sans-serif;line-height:19.1875px">incremental</a><span style="font-size:13px;color:rgb(0,0,0);font-family:sans-serif;line-height:19.1875px"> collector"... That'd be nice!</span></div>
<div class="gmail_extra" style>ObjC and WinRT are both used successfully on embedded hardware, I'm really wondering if this is the way to go for embedded in D.</div><div class="gmail_extra" style>V8 uses an incremental collector (somehow?), which I've been saying is basically mandatory for embedded/realtime use. Apparently Google agree.</div>
<div class="gmail_extra" style>Clearly others have already had this quarrel, their resolutions are worth consideration.</div><div class="gmail_extra" style><br></div><div class="gmail_extra" style>Implementing a ref-counted GC would probably be much simpler than V8's mythical incremental collector that probably relies on Java restrictions to operate?</div>
</div>