• 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: NSTextView won't deallocate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextView won't deallocate


  • Subject: Re: NSTextView won't deallocate
  • From: Peter <email@hidden>
  • Date: Mon, 18 Jul 2011 23:30:59 +0200

Yes - so the more appropriate question is why it was retained 4 times.
I don't see Cocoa doing it.
It's the programmer - mostly.
Could you give us more code?

Cocoa gives us a very reliable way to know, when an object is released: If the reference count goes down to 0.
The question now is how to bring it down to 0.

Maybe these could be of help:

<http://www.friday.com/bbum/2010/01/10/using-malloc-to-debug-memory-misuse-in-cocoa/>
<http://chanson.livejournal.com/147902.html>

Both have some special tips which helped me a couple of months ago.

Am 18.07.2011 um 16:17 schrieb Ryan Joseph:

> Sure, I get reference counted memory and it could very well be true that Cocoa has no intent on releasing this at anytime I could expect and that was its design.
>
> If that's true when I would ask WHEN will it be deallocated? I'm leaking memory like crazy allocating these objects and would argue it's bad design on Cocoas part to not give the programmer a reliable way to know when it's memory will be released, as for example we may need to perform some clean up when the object is released.
>
> I wonder why Cocoa has retained it 4 times and what it plans to do with it since I don't see thing that will cause the memory to be released.
>
> Thanks.
>
> On Jul 18, 2011, at 8:07 AM, Peter wrote:
>
>> Maybe I am missing something, but given your example - which in some sense contradicts your comment, why do you expect dealloc to be called?
>> If the retain count is in fact > 0 after the release (4 in your example below) dealloc is not called, since the view can not yet be deallocated.
>> View.release just means "*I* (i.e. the caller) don't care about you any longer". But if some other object still cares (i.e. the retain count > 0, as in your example), dealloc won't be called. In short: release != dealloc. Or the other way round: only after x retains are balanced by the same number of release messages, dealloc eventually will be called by the runtime and the object is  finally cleaned up and purged from memory.
>>
>> Sorry if I am getting you wrong and point out the obvious ...
>
> Regards,
> 	Ryan Joseph
> 	thealchemistguild.com

_______________________________________________

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: NSTextView won't deallocate
      • From: Kyle Sluder <email@hidden>
    • Re: NSTextView won't deallocate
      • From: R <email@hidden>
References: 
 >NSTextView won't deallocate (From: Ryan Joseph <email@hidden>)
 >Re: NSTextView won't deallocate (From: Peter <email@hidden>)
 >Re: NSTextView won't deallocate (From: Ryan Joseph <email@hidden>)

  • Prev by Date: Re: UIButton on top of other objects
  • Next by Date: Re: NSTextView won't deallocate
  • Previous by thread: Re: NSTextView won't deallocate
  • Next by thread: Re: NSTextView won't deallocate
  • Index(es):
    • Date
    • Thread