discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Interesting difference in memory management of MacOS Foundation and


From: Mathias Bauer
Subject: Re: Interesting difference in memory management of MacOS Foundation and GNUstep
Date: Mon, 17 Feb 2014 14:33:20 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.3.0

Hi,

in case somebody else is also interested in this: it seems that Apple's runtime "protects" the developer by ignoring changes to the retain count as soon as the object entered its deallocate method. Wrong decision, IMHO.

Regards,
Mathias

Am 14.02.14 10:53, schrieb Mathias Bauer:
Hi dear list members,

I have ported most parts of the CocoaHTTPServer from Robbie Hanson
including GCDAsyncSocket to Linux and found an interesting difference in
memory management.

Here's the dealloc function of GCDAsyncSocket:

- (void)dealloc
{
    LogInfo(@"%@ - %@ (start)", THIS_METHOD, self);

    if (dispatch_get_specific(IsOnSocketQueueOrTargetQueueKey))
    {
        [self closeWithError:nil];
    }
    else
    {
        dispatch_sync(socketQueue, ^{
            [self closeWithError:nil];
        });
    }

This method crashes on Linux when the dealloc function in not called in
the socket or target queue as the block that calls closeWithError is
executed in this case. Catching "self" in it increments and after block
execution decrements the retain count of "self". Doing this in a dealloc
method of course leads into disaster.

But the same code does not crash on MacOS or iOS, even if the block
containing closwWithError is executed.

I don't understand that, but maybe somebody knowing the differences
better than I can explain that.

Best regards,
Mathias

_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnustep



reply via email to

[Prev in Thread] Current Thread [Next in Thread]