Re: NSView out of memory problem

2008-04-02 Thread Andre Schnoor
Am 02.04.2008 um 01:05 schrieb Graham Cox: As I said, it says nothing about how it's implemented. Chances are, it will avoid creation of an unnecessary NSBezierPath object, but relying on that being the case is folly. On 2 Apr 2008, at 2:23 am, Matthew Whillock wrote: The class reference

Re: NSView out of memory problem

2008-04-01 Thread Matt Gough
On 1 Apr 2008, at 14:40, Leslie Smith wrote: I'm sure I'm missing something. Yes. An understanding of Autorelease pools (and presumably Cocoa memory management in general) http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html The unoptimal way to fix your

NSView out of memory problem

2008-04-01 Thread Leslie Smith
Hi: I have a Cocoa application which draws a (very) large number of line segments using the code below in a loop, in drawRect, in a subclass of NSView. p1 = [NSBezierPath bezierPath] ; [p1 moveToPoint: linebottom] ; [p1 lineToPoint: linetop] ; [p1 stroke] ; (These are the outputs from a

Re: NSView out of memory problem

2008-04-01 Thread Matthew Whillock
Blimey! I went to (most) of your lectures! Networks I think it was. Software Engineerng MSc 1985/6 or thereabouts... Anyway, have you considered using +strokeLineFromPoint:toPoint: instead? No need for an NSBezierPath instance. Cheers, Matt (Ok then, some of your lectures) Hi: I have a

Re: NSView out of memory problem

2008-04-01 Thread Graham Cox
Are you sure? This could be just a convenient interface for creating a bezier object with the points passed, stroking it and releasing or autoreleasing it. The docs say nothing about how it's implemented. A better idea might be to create ONE bezier object at the top of the loop, collect

Re: NSView out of memory problem

2008-04-01 Thread Jean-Daniel Dupas
Le 1 avr. 08 à 14:50, Matt Gough a écrit : On 1 Apr 2008, at 14:40, Leslie Smith wrote: I'm sure I'm missing something. Yes. An understanding of Autorelease pools (and presumably Cocoa memory management in general)

Re: NSView out of memory problem

2008-04-01 Thread Graham Cox
On 1 Apr 2008, at 11:40 pm, Leslie Smith wrote: Hi: I have a Cocoa application which draws a (very) large number of line segments using the code below in a loop, in drawRect, in a subclass of NSView. p1 = [NSBezierPath bezierPath] ; [p1 moveToPoint: linebottom] ; [p1 lineToPoint:

Re: NSView out of memory problem

2008-04-01 Thread Gorazd Krosl
Hi Leslie, NSView does not store any drawing. If the code bellow is executed in the loop as you are indicating and possibly several thousand times, each time through the loop you are creating a new autoreleased NSBezierPath. If this is the case, you should include NSAutoreleasePool and drain or

Re: NSView out of memory problem

2008-04-01 Thread Matthew Whillock
The class reference has this to say about it: Strokes a line between two points using the current stroke color and the default drawing attributes. + (void)strokeLineFromPoint:(NSPoint)point1 toPoint:(NSPoint)point2 So it will just draw a line. Cheers, Matt Are you sure? This could be