[Top][All Lists]

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

Re: GNUstep and valgrind

From: amon
Subject: Re: GNUstep and valgrind
Date: Fri, 16 Mar 2018 10:18:30 -0500
User-agent: Roundcube Webmail/1.3.4

Note that even if you’re using GCC, if you’re using libobjc2
then you can call the ARC objc_retainAutoreleasedReturnValue
function explicitly, rather than sending a -retain message to
an autoreleased value.  This will pop the top object from the
autorelease pool and transfer ownership of it to the caller.
The caller is then responsible for releasing it.

In a system with realtime requirements, autorelease pools are
a really bad idea.  They will introduce pauses proportional
to the total number of objects in the pool when they are
destroyed.  Most realtime systems don’t allow allocating
objects at all, so Objective-C is probably exactly the wrong
choice for them.

That is of course true. The hard real time sections are
called from ObjC but once running they do carefully optimized
C code under Linux RT priority.

The rest of it is in other threads or processes which take
what time they can get and communicate with it. It works and
has been proven in quite real world circumstances. However,
the ObjC side never has a chance to sleep even if it is running
at lower priority.

The solution of multiple pools is already in use in those places
where there is a known start/finish to a particular operation.
That still leaves me with areas in which that is not feasible.
Also, I am looking for a way to make things more deterministic
so that I can write up the paper work that will doubtless be

Your suggestion looks rather interesting. Now whereever I can,
I use [[Foo alloc] initmethod], but there are cases where things
like NSString do not have an appropriate init method or one that
is even close to what I need. In those cases, strictly internal
to a given method, I would use your method. Here's an example,
where arglist and cmdline are IVAR's of the object being init'd
(or re-init'd). Don't focus too much on this particular case, it
is just one example that I happened to run down yesterday.

            [arglist release];
  arglist = [[[NSMutableString stringWithCString: [cmdline cString]]
               componentsSeparatedByString: DELIM] retain];

This happens inside an init. arglist is release by the dealloc
method. However, NSMutableString insists on making it autoreleased.
I want to make it not do that. So would you say that if I


that will take that NSString out of the pool so that my dealloc
method will have the sole responsibility for the last release?

My goal is to get to this state of nirvana:

         // zone used = n bytes
         obj = [Foo new];
         // zone used = n+m bytes
         [obj release];
         // zone used = n bytes.

Where Foo could have a highly complex set of IVARS and be
used in complex ways before release.

Next question is whether ARC is available. I have fairly old
LTS (we only use LTS) Ubuntu and Mint systems that are pretty
much bog standard vendor out of the box single board systems. I
typically do add the tool chain to one so I can natively build
on an ARM machine, but never do any major mods beside that. It is
habit right now, but in the long run every change will have to be
tracked, explained and documented and a pain...

|   Dale Amon                  Immortal Data                    |
|   CEO             Midland International Air and Space Port    |
| address@hidden       "Data Systems for Deep Space and Time"     |

reply via email to

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