Re: Optimizing NSView's drawRect
Re: Optimizing NSView's drawRect
- Subject: Re: Optimizing NSView's drawRect
- From: Greg Herlihy <email@hidden>
- Date: Thu, 24 Nov 2005 00:22:30 -0800
- Thread-topic: Optimizing NSView's drawRect
The slowness in your application certainly suggests a substantial memory
leak. I would use ObjectAlloc (found in the Developer Tools applications) to
examine the application's memory usage. To do so, first launch ObjectAlloc
and have it launch the app being tested. Next use the "mark" button (shaped
like a chevron) to establish a baseline of memory usage. Also check the
"show since mark" checkbox.
Next, repeatedly perform a specific action in the app (such scrolling around
in a window) that may be leaking memory. While performing this action the
total number of allocated objects and the amount of memory in use that
ObjectAlloc displays should remain more or less constant. If that is not the
case, and ObjectAlloc shows dozens, hundreds or thousands of surplus objects
created then there is a memory leak. Fortunately, ObjectAlloc can record
where objects were allocated, (and even where they were retained, released,
and deleted). This information will tell you which objects the program needs
to be releasing.
Greg
On 11/23/05 8:00 PM, "David Chan" <email@hidden> wrote:
> Hi all,
>
> I have got a NSView which basically draw a shelf with books a la delicious
> library. I provide the zooming function for user using NSSlider and user can
> also resize the window. I notice that after zooming in and out, resizing
> windows and scrolling up and down for a while, my program would tend to slow
> down and sort of hang a bit, though it never crashes so far. It also take
> considerably longer time to close upon quitting.
> I have untick the 'continuously send action while sliding' option from
> NSSlide to lessen the call for redrawing on zooming but when it comes to
> resizing window and scrolling, there is nothing I can do- drawRect seems to
> get called numerous times as user scroll.
> And my drawRect is inevitably a costly method to call as I would have to
> travel through my array of book collection, defining the coordinate and draw
> it one by one.
>
> I am still strugling with the 'release' part of obj-C as I have been using
> Java all this while, so I may have lots of object unreleased within my
> function too. I don't know if that could result in the above problem.
>
> Any idea how I should optimize my program or what could possibly went wrong
> with my program? Thanks alot..
>
> Regards
> David
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden