discuss-gnustep
[Top][All Lists]
Advanced

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

Re: NSOperationQueue - Killed after 40 seconds


From: Philippe Roussel
Subject: Re: NSOperationQueue - Killed after 40 seconds
Date: Sun, 23 Mar 2014 11:25:57 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

[gnustep-discuss back on cc]

On Sun, Mar 23, 2014 at 03:40:07AM +0000, Ivan Vučica wrote:
> On 22.03.2014. 17:23, Philippe Roussel wrote:
> > Hi,
> >
> > On Sat, Mar 22, 2014 at 05:17:55PM +0100, Matthias Rudolph wrote:
> >> @interface ValueRow : NSObject {
> >>     int value[5000000];
> >> }
> > Each ValueRow uses 5000000 * 4 bytes on the stack ?? 
> It is my understanding that, being dynamically allocated, any
> Objective-C object is actually held on the heap and not on the stack.
> Were this a local variable, then yes, this would end up on a stack. As
> is, it ends up elsewhere and is less critical.

Ooops, you're right of course, those arrays are dynamically allocated
with ValueRow objects...

> That said, as Philippe mentioned, cca 20MB allocated in this way is
> worrying by itself, so consider allocating memory as-needed (unless
> there is a very good reason why he believes the memory should be
> allocated in ~20MB chunks).
> 
> I'd also advise looking for why the memory is not freed as soon as
> possible (because it's worth striving for memory to be freed as soon as
> realistically possible). While autorelease pools are, in most cases, an
> excellent piece of magic, it may be worth exploring surrounding critical
> parts of code with NSAutoreleasePool * pool = [NSAutoreleasePool new];
> and [pool drain]; (or release, as appropriate). (And if you're willing
> to use new language features, there's @autorelease {}.)
> 
> Just because something magically works on OS X does not mean it is
> necessarily correct. Without ability to peek into your code, I can only
> guess that there may be an assumption that something will not be
> retained by the framework, in a situation where GNUstep reserves the
> right to do so and perhaps autoreleases an object. If GNUstep does
> retain something, then autoreleases the parent object, manual creation
> of an autorelease pool might help.
> 
> --
> Ivan
> 

-- 
Duct tape is like the Force. It has a light side and a dark side, and it holds 
the universe together.




reply via email to

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