> Am 20.03.2018 um 07:31 schrieb amon <a...@vnl.com>:
> 
> Richard:
> 
> Thanks. I will look at that.
> 
> And btw, to the person who suggested @autorelease... I was
> certain it would not compile, but I tried it anyway. Needless
> to say, it did not compile.
> 
> I did try coding
> p=[NSAutoreleasePool new]; do something; [p release];
> and in some cases it seemed to help. In others it did not.
> I'll be digging deeper tomorrow and I will give the macros
> you suggested a try.

Well, there may be this pattern:

while(YES) {
        arp=[NSAutoreleasePool new];
        object = do something
        var=[object retain]
        [arp release]
}

Then, the object will leak despite using an ARP and releasing it.
The issue is that var=[object retain] will *not* release the previous
var. That is what the ASSIGN macro would be good for.

Unfortunately I also don't have a clear method to track down such
issues especially if they are distributed over multiple frameworks.

> 
> If nothing else, I am getting a much better handle on how and
> when memory gets sucked up.
> 
> A question on NSHost then. If NSHost essentially returns a
> cache of something like what NeXT used to call Class Objects,
> like the old Printer Class that always returned the same
> object (A technique I still use for something btw)

this is the Singleton Pattern: https://en.wikipedia.org/wiki/Singleton_pattern

> then that
> would be less troubling.
> But to be clear, If I create an NSHost
> for "10.0.0.1" in one place in the code, and then some entirely
> other area creates one with the same IP, I presume you are
> seeing that it will return a pointer to the same object? That
> there will never be two NSHosts with the same IP?

You can find out by running

        NSLog(@"%p", [NSHost hostWithAddress:@"10.0.0.1"]);

twice in succession.


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

Reply via email to