• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Leak when animating Core Animation Superlayer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Leak when animating Core Animation Superlayer


  • Subject: Re: Leak when animating Core Animation Superlayer
  • From: "Gustavo Eulalio" <email@hidden>
  • Date: Sun, 1 Jun 2008 09:15:52 -0300

Well, I'm novice to Cocoa/ObjC programming, so, I might be wrong. But
I see you're setting a new frame on l2 every time fromTimer: is
called, but you never release the old one. The following may solve it,
if that's the problem.

- (void) fromTimer: (NSTimer *) t
{
    [l2.frame release]
    l2.frame = CGRectMake((double)random() / RAND_MAX*30, (double)random() /
        RAND_MAX*30, (double)random() / RAND_MAX*40, (double)random() /
        RAND_MAX*40);
    l1.opacity = (double)random() / RAND_MAX;
}

Or are you using the garbage collector?
By the way, shouldn't this be done via an accessor method? [l2 setFrame:...]

--
Gustavo Eulalio
email@hidden

On Sun, Jun 1, 2008 at 6:03 AM, Stéphane Droux <email@hidden> wrote:
> On Sun, Jun 1, 2008 at 8:49 AM, Brian Christensen <email@hidden> wrote:
>
>> On Jun 1, 2008, at 2:55 , Stéphane Droux wrote:
>>
>>  When I run the program in Mallocdebug, it seems that one of the threads
>>> used
>>> by Core Animation to animate the layers doesn't release its memory.
>>> So it looks like a bug in Core Animation. However, since animating
>>> non-leaf
>>> layers is such a core feature of Core Animation, I guess there's something
>>> missing in my code
>>>
>>
>> Are you sure you're getting a leak? I ran your sample code in Instruments
>> with the Object Alloc and Leaks tools and I didn't detect any leaks. Object
>> allocation and memory usage remained constant. Whether l1 or l2 were being
>> animated made no discernible difference.
>>
>> /brian
>>
>>
>
> Brian,
>
> You're right, when l1 is animated the memory usage increases for a while and
> then reaches a peak from which it remains constant.
>
> I think my example wasn't complex enough to reproduce my application
> behaviour.
> I've changed the timer function to do random animations and this time it
> really "leaks":
>
> - (void) fromTimer: (NSTimer *) t
> {
>    l2.frame = CGRectMake((double)random() / RAND_MAX*30, (double)random() /
> RAND_MAX*30, (double)random() / RAND_MAX*40, (double)random() /
> RAND_MAX*40);
>    l1.opacity = (double)random() / RAND_MAX;
> }
>
>
> I ran it in Object alloc and can see a trend of increasing memory usage :
> the memory usage keeps changing up and down but the general trend is up and
> it doubled after a minute or so.
>
> Could that be caused by some kind of caching in  Core Animation ?
> If it is, is there a way to flush the cache ?
>
> Thanks
> Stephane
> _______________________________________________
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Leak when animating Core Animation Superlayer
      • From: "Stéphane Droux" <email@hidden>
References: 
 >Re: Leak when animating Core Animation Superlayer (From: Brian Christensen <email@hidden>)
 >Re: Leak when animating Core Animation Superlayer (From: "Stéphane Droux" <email@hidden>)

  • Prev by Date: Re: email
  • Next by Date: Re: runloops and NSURLConnection
  • Previous by thread: Re: Leak when animating Core Animation Superlayer
  • Next by thread: Re: Leak when animating Core Animation Superlayer
  • Index(es):
    • Date
    • Thread