iPhone vs Android
deadalnix via Digitalmars-d
digitalmars-d at puremagic.com
Wed Sep 14 00:16:04 PDT 2016
On Wednesday, 14 September 2016 at 05:38:38 UTC, Shachar Shemesh
wrote:
> On 14/09/16 02:59, Walter Bright wrote:
>>
>> Memory allocated with malloc() is unknown to the GC. This
>> works fine
>> unless a reference to the GC memory is inserted into malloc'd
>> data,
>> which is why there's an API to the GC to let it know about
>> such things.
>>
>
> But if you do want to allow it, then my original problem comes
> back. You have to scan the malloced memory because you are not
> sure where that memory might contain pointers to GC managed
> memory.
>
> And the hybrid hybrid approach (i.e. - only some of the memory
> allocated by malloc is scanned) is a wasp nest of potential
> bugs and problems.
>
> Shachar
Cool down, take a step back.
There are memory management technique that can give you good
result in most case, but will degenerate is few others. For
instance RC doesn't handle cycles, plays poorly with exceptions,
and so on.
There are ways to make RC work in all these case, but it is has
severe drawbacks. Now, if you allocate using a GC, and use RC on
top of it, you get 99% of the garbage cleaned up as you expect.
But it allows the RC system to just delegate to the GC for cases
it is not good at.
That way you get very occasional collection cycles to the point
where it is usually not a problem, and if you are smart about it,
you can even trigger them yourself at appropriate time. If 99% of
the garbage is cleanup up by the RC mechanism, the the garbage
accumulate at 1% the rate of what it would with a 100% GC system,
and, consequently, you can run collection 1/100 time what you
would with a pure GC system with the same memory overhead.
Now you may ask, how am I so sure that this is working great ?
The short answer is PHP.
More information about the Digitalmars-d
mailing list