[Top][All Lists]

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

Re: GNUstep and valgrind

From: Andreas Fink
Subject: Re: GNUstep and valgrind
Date: Tue, 20 Mar 2018 08:59:08 +0100

>> How GnuStep has implemented drain vs. release I would have to check. But if 
>> you follow the Apple documentation, the GnuStep implementation should follow 
>> along (with a few exceptions which are not implemented [yet]). So calling 
>> drain would be a safe bet.
> Indeed. It is safer. Unless you have code that you still want to compile on 
> <OS X 10.4 systems. Then, release is safer because it still works on 10.13.
> So it seems to be impossible to find a general answer :(

the answer would be to have the compiler use @autoreleasepool { } ...
(I wonder if thats any different in reality)

> Anyways, this does not help the original leak issue.

One thing to be careful about , especially in embedded systems who run as 
background tasks, is the fact that every thread has its own autorelease pool. 
And long running tasks should drain their pool frequently.
Some errors I had in my daemons in the early days was like having a way too big 
autorelease pool which almost never gets drained. So objects where piling up 
all the time. My stuff is heavily multithreaded and I have background threads 
which sit on sockets and live long. So when you read from sockets, process some 
stuff and read from sockets again, you need to have temporary pools being 
created on the fly.
What I often do is to run my own multithreaded execution queue. So if I have a 
task to do, I throw an object on to the queue. The queue executor then picks an 
object, creates an autorelease pool, calls the object's main method and drains 
the pool.

reply via email to

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