leak:
Malloc 48 bytes per incident
libsystem_c.dylib
studup
I've seen this in our project continually, and we're not using ARC. I
don't remember exactly where this arises at the moment, but strdup leaks
seem to be widely seen but not all that serious (it didn't seem that much
memory was
On Mon, Mar 19, 2012 at 1:35 PM, Sebastian Celis
li...@sebastiancelis.comwrote:
1) Embrace @properties...Exposing _ivars in header files is
gross. You never want people to access them directly, so don't make
those declarations public at all.
2) Technically, nothing is truly private in
I think most of this is in the NIB loading guide and the template code for
UIViewController subclases (and the code auto-generated when you add
outlets in Xcode using the mouse) does this.
Thanks. I'm not using ARC and won't be for this release of my app.
The posted link was for the Mac OS
My UIAlertView version has exactly the same problem. Are you sure it
worked for you?
Yep. For some reason my business partner's iPhone 4S gets hammered with an
outrageous number of memory warnings, whereas my iPhone 4 rarely does. He
doesn't seem to be running anything extra in the
OK, thanks for the info and reference material.
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
The Apple doc for iOS says:
From a practical perspective, in iOS and OS X outlets should be
defined as declared
properties. Outlets should generally be weak, except for those from File’s
Owner to top-level objects in a nib file (or, in iOS, a storyboard scene)
which should be strong. Outlets that
Thanks. I didn't know whether they meant weak as a keyword necessarily, or
simply the concept of a weak reference.
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the
OK, I think I know why there weren't any leaks.
Per (possibly old) examples, I have IBOutlet in both the member-variable
declarations and the property declarations.
Now I'm realizing that IB will show two outlets: one for the member
variable itself, and one for the property when you have this:
I went through and removed all the IBOutlet notation from the members and
reconnected everything to the properties in IB. Also added release calls
for all the controls in dealloc. The app appears to be quite solid, with
no leaks or analyzer issues detected. I'm calling it done!
Needless to
I'm doing an iPhone app. I'm not doing any Mac app.
I should simply have said the nib-loading behavior.
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators
Well, my code doesn't show things being allocated and assigned to the
IBOutlets, but it shows a bunch of releases of the associated members. As
far as I can gather, the code is now correct. It is this asymmetry that
strikes me as messy and error-prone.
I have this in my header file:
*
**
@property (nonatomic, retain) UIImagePickerController* imagePicker;
**
*
The analyzer is complaining about lines like this (but not always):
*
self.imagePicker = [[UIImagePickerController alloc] init];
[self.imagePicker release];
*
I do this in many
On Mon, Mar 19, 2012 at 9:29 AM, Rhythmic Fistman rfist...@gmail.comwrote:
I have this problem too. I have a small non-storyboard project that
reproduces it a TSI in progress.
Woah, finally, someone else emerges! Please let us know what you discover!
Does your scenario have anything in
On Mon, Mar 19, 2012 at 6:18 AM, Roland King r...@rols.org wrote:
No, the analyzer is right and your code is somewhat confused. I'm trying
to figure out how you ended up with code like that, did you find you had an
extra retain somewhere and need to get rid of it?
Yes. The allocated object
On Mon, Mar 19, 2012 at 3:47 PM, Roland King r...@rols.org wrote:
And do you now understand why you are releasing the wrong thing?
Well, I understand why my code just happens to be releasing the right
thing, but easily couldn't. Obviously the getter might be coded to return
anything,
Yep, thanks. Someone pointed that out.
I went through my whole project and audited every file for memory
management, reinstating properties for everything. After forgetting not to
use properties in the init and dealloc methods and having to correct that,
the app is running great and there's not
Are you using NSViewController or NSWindowController?
UIViewController and derivatives.
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at
With my recent battles against memory warnings and deleted views, I'm
auditing my code to make sure that nothing tries to access controls while
the view is unloaded. Is it typical to enclose a lot of screen-validation
routines and control access in a if([self isViewLoaded])statement?
just use isViewLoaded, it's a property of the UIViewController, don't need
to track it yourself.
BAH! I looked for this sort of thing under the properties of
UIViewController, not methods. Thanks.
___
Cocoa-dev mailing list
This pattern is pretty questionable though in terms of OO — you have one
class (NSNib, UINib, etc.) directly setting instance variables in another
class (your view controller) and using runtime functions to hack around
things like @private.
How do you figure? I'm not doing any manipulation
How do you think that (NS)|(UI)Nib — an unrelated class that shouldn’t
have access to your private ivars — sets the outlet variables to your nib
objects? It does it via runtime hackery. If you declare a property, on the
other hand, it just calls the setter. Much cleaner and more OO, if you
I have a member variable to hold an NSDate:
NSDate* _firstBadAccuracyTime;
At some point, something happens and I set this value to now:
_firstBadAccuracyTime = [NSDate date];
On my next trip through this function, I calculate how long it has been
since I set this date:
NSDate*
If a Cocoa method name doesn't begin with “alloc”, “new”, “copy”, or
“mutableCopy”, then the returned object is autoreleased.
Thanks, Dave. That's what I thought. But I don't understand why I need to
retain it then; it's assigned to a member pointer. Why does it get
released, and when? If
I create another NSDate, on the stack, to hold now for use within that
function. Do I need to retain that too?
Yes.
Hm, Apple's doc says:
Cocoa’s ownership policy specifies that received objects should typically
remain valid throughout the scope of the calling method.
This leads me to
I did read the memory-management docs a long time ago, and I've run my app
through both Leaks and the analyzer. I avoid using properties because I
carefully manage my allocations.
I think the hole in my knowledge was limited to autorelease. I never use
autorelease in my code, so my exposure to
BTW, thanks for all the answers. I appreciate it!
Gavin
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
On Sat, Mar 17, 2012 at 4:55 PM, Roland King r...@rols.org wrote:
Hmm - with respect - autorelease is an implementation detail. Nothing says
that objects created through the convenience constructors like [ NSDate
date ] have to be autoreleased, they just have to be valid for long enough
to be
On Sat, Mar 17, 2012 at 5:19 PM, Eeyore eey...@monsterworks.com wrote:
I believe you were also on the discussion of properties vs. direct ivar
access. This ties into that discussion.
Yep. That's why I mentioned that I see new merit to properties.
You would still need to release the object
The situation is pretty simple: a view controller at the top of our
navigation controller's stack presents a modal view controller.
When the user's done with the modal view, he makes one of several choices
that call the modal controller's delegate and cause the delegate to dismiss
the modal view.
Thanks for asking this, Brian. I've wondered the same thing, and in fact I
went through my code and removed almost all property declarations from my
view controllers. Since most properties are declared as retain, you're
just increasing your bookkeeping to avoid leaks. Not to mention the sheer
On Fri, Mar 16, 2012 at 7:53 PM, Roland King r...@rols.org wrote:
You've sure had a lot of problems with this!
Yeah, this is ridiculous. Researching it, I found that Instagram had the
same white-screen problem for a while. Unfortunately, I've found no way to
contact them.
There's clearly
On Fri, Mar 16, 2012 at 9:45 PM, Roland King r...@rols.org wrote:
I think chances are you are still somehow calling a method on a view
controller or similar which has been evicted.
I took a hard look at the two underlying controllers to make sure that they
are not referring to controls when
No. But if you've presented a modal view controller, your entire view
hierarchy (self.view) has been ripped out of the window, and if a memory
warning arrives, then self.view will be set to nil. What happens next
depends on if you implemented -viewDidUnload properly or if your view
Well, at any rate, I have no such subview property.
I've also found that among my series of modal presentations, there's a view
that's displayed modally, whose user interaction works just fine, but whose
viewWillAppear and viewWillDisappear methods are never called. As far as I
know, it could be
When our iPhone app is launched for the first time, it checks the user's
iCloud account to see if he has installed our app on another device. If
so, he'll have a unique ID that we've stored in his iCloud account, which
is a database key that we use to manage his online content. We grab it and
In the vast majority of cases where I've seen this behavior, it is because
in your delegate handler for the UIImagePickerController, you assign the
returned image directly to a UIImageView that you have in your view
hierarchy. If you've recently gotten a memory warning, then this image view
Thanks for the feedback, Roland.
On Sun, Mar 4, 2012 at 6:07 PM, Roland King r...@rols.org wrote:
I would suspect that and change it so that either
1 the new view controller is pushed by the viewDidDisappear of the
dismissed modal one or
This would require excessive knowledge of the
How do you know the white view is screen-sized and has no superview?
Actually a UIView which you can see and yet has no superview is probably
just the UIWindow itself.
I write info about it to a log, in viewDidLoad.
How about the view which has just been loaded? Does it have a superview?
OK, after our controller's view gets blown away on the memory warning, it
does appear to be reloaded from the nib when it's time for redisplay. At
least the IBOutlet members are non-nil in viewDidLoad (I nilled them on
viewDidUnload).
So it appears that the controller's view is reloaded from the
The Apple doc says,
If the view controller has an associated nib file, this method loads the
view from the nib file. A view controller has an associated nib file if the
Thanks guys.
The problem happens with no override of loadView. I only overrode it to
verify that it was being called after the memory warning, and to verify
that nibName was set.
In viewDidLoad, I just instantiate a data collection and progress indicator.
Well, I've verified that the view controller has the correct name of the
nib when it tries to reload the view after a memory warning.
So this seems like a pretty big Cocoa bug, which unfortunately only one
(remote) person on our team can reproduce reliably. I know Instagram
encountered this same
Hi all.
View controllers that are buried in the navigation stack (or otherwise have
their views obscured) set their views to nil when they receive a memory
warning. This makes sense temporarily, because the views aren't visible.
But when the overlapping views are dismissed, how is the nillified
Hi all. I'm looking for leaks in my iPhone app and apparently finding
some. Unfortunately, Instruments will not show my app's symbols, making it
pretty worthless.
I've tried Re-Symbolicate Document, but this does nothing. When I
navigate to the location of the app and dSYM files (which do
Thanks again, Conrad.
Are there *any* connections to your control (other than the
superview/subview relationship)? I see a _NSSetObjectValueForKeyInIvar
in your retain trace, which just be doing something internal, but it
makes me wonder.
There is an IBOutlet for it, but that's it.
I
I have a breakpoint in the problematic object's dealloc method, and it is
never called when I'm testing it, even when I know that the parent has been
deallocated.
Conveniently, the deallocation of the control only occurs when the phone is
running untethered (not under the debugger). It's
Made an interesting discovery. If I invoke a screen modally over the
problematic one, simulate a low-memory warning, and then dismiss the modal
screen... the control gets deallocated. After several attempts it will
crash with a bad access (apparently at calling [super dealloc]).
Anyway, this is
Hi all.
Our app is crashing on the deallocation of a custom control, which resides
on a view that's pushed onto the navigation controller's stack.
The problem is that this view is almost never deallocated, even long after
the user dismisses it with the Back button. It's not a leak, so I guess
Thanks for the response.
Even *if* deallocation occurs later, that shouldn't cause a crash.
I'm not suggesting that this is what's causing the crash. It's simply
preventing me from debugging the problem, because I can't reproduce it on
demand.
It's just a crash in the control's dealloc
It's just a crash in the control's dealloc method:
0x0019f56e -[ThumbStripView dealloc]
But what is the crash? EXC_BAD_ACCESS?
Don't know. The above is all that appears in the crash log, and it's so
hard to reproduce that I've never seen it while running under the debugger.
If so, I
On Wed, Feb 8, 2012 at 6:41 PM, Alex Zavatone z...@mac.com wrote:
I'd check to see if it's already been deallocated.
Thanks Alex. I don't know which item you mean (the control or its parent
view), but I have breakpoints set in both of their dealloc methods and
those breakpoints do work. So I
AH.
There you go. You gotta realize that if you release an object more than
once, that WILL end up crashing, though not necessarily when you expect.
Hm. I didn't say this (because I thought it was obvious) , but I released
it three times in succession *as an experiment to force the
Thanks guys, but you can't attach to a process with Leaks.
This turned out to be a bug in Xcode 4.2, apparently. The app simply never
ran. Someone mentioned that Xcode 4.2.1 existed (I must've missed the
notification somehow), so I downloaded it and installed it. Instruments
and Leaks now
So... no one knows how to launch an app on the device with Instruments?
Thanks anyway.
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at
Hi all.
After finding an alleged answer on the Web (since the Apple
documentation refers to the nonexistent Run Start with Performance
Tool menu in Xcode), I still can't get my app running in Instruments.
Choosing Profile from the Product menu does cause Instruments to
prompt for a template, but
Our app has suddenly started exhibiting a strange delay when resuming
from the background; it gradually takes longer and longer to
reactivate the UI. Eventually, the app takes several seconds to
resume, and crashes for failure to resume in time.
I looked at the crash log, and found four threads
Did the crash-log-generation procedure and got this after our screen
went totally white:
Unknown thread crashed with unknown flavor: 5, state_count: 1
Then we have these, which apparently result from force-quitting the
app during the white screen:
Exception Type: 0020
Exception Codes:
Good info. Thanks, guys!
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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
This just started happening recently, but then again I've made lots of
changes to our app. It's not very frequent, and so far there's no
discernible pattern. But every once in a while, the entire phone
screen will turn white and there's no way to get rid of it in the app.
There's no status bar,
Thanks, Mike.
There's nothing in the console. The whole call stack at the time of
the crash is this (when I create the operation on the main thread):
#0 0x00396336 in -[NSOperation observationInfo] ()
#1 0x0036823a in _NSKeyValueRetainedObservationInfoForObject ()
#2 0x00379c98 in
Thanks to all who answered. It was a simple boneheaded maneuver:
Failing to call [super init] in the initialization method of my derived class.
DUH. Works fine now!
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin
Hi all. Working on an iPhone app and encountered a stumper.
I have various kinds of operations (derived from NSOperation) to do async
queries over the Internet. As is the norm, I determine when they're
finished by observing their isFinished property, and getting the results in
Hi all.
I've configured our app for iCloud usage and push notifications with
the appropriate entitlements, under a provisioning profile that is set
up for these, and a developer profile that's associated with this
provisioning profile.
The application identifier matches what's specified in the
Hi all.
My app just started crashing on launch, and I traced it to this call
returning nil:
NSString* versionString = [[NSBundle mainBundle]
objectForInfoDictionaryKey:(NSString*)kCFBundleVersionKey];
Anyone know why this would suddenly start happening? Looking in the
app's plist,
Turns out there's an Xcode bug behind this. Hard to imagine, I know.
We don't use build numbers; just version numbers. I noticed that the
target summary's Version field was blank, but the Build field wasn't.
Swapping those states led Xcode to inexplicably remove the version
from the plist
Hi all. I've been wrestling with a crash in our app for a while now.
It occurs when an MKMapView calls its delegate to get an annotation
view. The problem is, there shouldn't be any MKMapView in existence.
The view containing it has long since been popped.
The MapView was part of a view loaded
Examples of weak references in Cocoa include, but are not restricted to,
table data sources, outline view items, notification observers, and
miscellaneous targets and delegates. [. . .] Likewise, when a delegate
object is deallocated, you need to remove the delegate link by sending a
All of the items were PNGs. I viewed them all in Adobe Bridge after
Preview wouldn't open them.
And changing that attribute in fact did NOT work; I'm still getting
the warning. On PNGs. Ridiculous.
Thanks for the insight though, guys.
___
Cocoa-dev
Hi all. Posting this here because I don't know where else to ask, and
it's vaguely development-related because I was simply trying to browse
icon files for my app.
I downloaded a set of icons. If I select all the PNGs in Finder,
right-click, and say Open, I get this asinine warning and then two
xattr -d com.apple.quarantine file...
At least that one still works! Thanks, Ron.
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at
I'm using an open-source controller that presents a grid of
thumbnails. It is designed to be full-screen, so there was no XIB
involved. Now I want to make it partial-screen and add some other
controls with IB.
___
Cocoa-dev mailing list
I should add that I've subclassed the grid controller to handle the
additional controls I'm adding to the view. The controller will not
be stored in the XIB.
I had to change the parent grid controller class to handle
initialization from a XIB, which included getting rid of loadView.
Now it can't
As a follow-up to my question about objects not being loaded from a XIB:
The view controller class I was using was not designed to be stored in
a XIB; it had no initWithNibName method and did have a loadView
method. The Apple doc makes it clear that these can't coexist in the
same class.
So is
Hi all.
I have a pretty simple iPhone XIB with of course the main view, then a
toolbar, a UITableView, and a custom grid view.
The controller (owner of this file) handles an initWithNibName and
calls up through one superclass to UIViewController's initWithNibName.
I've verified that this is
Thanks for the responses. The problem turned out to be that my view
controller's parent class had defined loadView, which didn't call the
base (UIViewController) loadView (and indeed, the documentation says
that a loadView method should NOT call the base).
Thus the XIB-loading mechanism was
UIKit takes a snapshot of the view hierarchy as it was when your application
goes into the background and uses that when it comes back to the foreground.
It remains until your UI has had a chance to redraw itself.
Thanks, David. I suspected as much. Looks like there's nothing to be
done
Hi all.
I'm seeing lots of duplicated keypresses on Lion. On my laptop,
they're often (but not always) coincident with a little blip of disk
activity; it's as if the system queues the keypress while it's
momentarily busy, and then issues it twice when the disk blip is over.
If I press a key
Hi all.
I put an MKMapView in my UI and tried to declare an IBOutlet for it,
but compilation fails with this error, in MKGeometry.h:
'isinf' was not declared in this scope
The line it's griping about is
UIKIT_STATIC_INLINE BOOL MKMapRectIsNull(MKMapRect rect) {
return isinf(rect.origin.x)
The man page for isinf says you will need to #include math.h and link
with -lm.
Thanks, but this is in Apple's code (MKGeometry.h). If I right-click
on isinf in the flagged line and jump to the definition, it finds it
in math.h.
___
Cocoa-dev
This is ridiculous. The whole project is at a standstill because of
this nonsense.
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at
First of all, thanks a lot for the responses.
I have compiled a couple of examples, and they do build. That makes
this all the more perplexing. The MapCallouts tutorial is one that I
tried.
In their file that uses MKMapView, these are the import statements:
#import UIKit/UIKit.h
#import
A search reveals that there are 29 math.h files on my system. Of
those, these don't clearly include isinf:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/include/c++/4.2.1/tr1
Are you compiling this file as Objective-C++?
Yes, the implementation is an mm file.
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at
Thanks very much for that analysis, Kyle.
This blows. All of our business logic is written in C++, which I'd
think is a common scenario (the paucity of business logic in the app
store notwithstanding). This problem is occurring in a UI controller
that needs to show information from a C++ object.
You should file a bug report anyway, because MapKit's headers should be
compatible with Objective-C++.
I will. The problem is that they're just going to bounce it back to
me with please provide a project that demonstrates this, and since I
don't know where cmath is coming in, I don't know how
If you preprocess your source file, the output will show every include and
where it came from. Not easy to interpret, but it's all there.
How do you do that?
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests
Good grief.
Anyway, thanks for all the help and time it took. I really appreciate it!
For now, my workaround was to paste
#define isinf(x)\
(sizeof (x) == sizeof(float )?__inline_isinff((float)(x))\
:sizeof (x) == sizeof(double)?__inline_isinfd((double)(x))\
My app is crashing after the user presses the Back button in the
navbar to dismiss a page that has a UIWebView on it, before the Web
view has finished loading. The Web view subsequently tries call its
delegate to say that the content has finished loading. In the Apple
docs I see this:
Hi all. Looking over some logs from my phone, I'm seeing lots of
Warning: [Warning] Deregistering for sleep notifications when we
have not registered
and also
Warning: [Warning] IORegisterForSystemPower failed
I'm also getting deny iokit-open RootDomainUserClient. It's pretty
much the combo
Hi all.
I'm trying to implement some robust network-failure handling in my
iPhone app. The test of whether my host is reachable returns YES even
when connected to a router that has no Internet connection. Apple's
docs say, A remote host is considered reachable when a data packet,
sent by an
Thanks for the response, Greg.
There are circumstances where a subset of the Internet's hosts may be
reachable. For example, you may be able to reach link-local names without a
broader Internet connection. Or you may be able to reach a host behind a VPN
only when the VPN is active. (I
Hi all. I'm having a layout problem on all my screens after they're
rotated. It seems as though the view loses all knowledge of the
navigation bar at the top after a rotation, so subviews are shoved up
under it. Check it out:
http://i.stack.imgur.com/mFALa.png
It's not just this view. It
Resolved. Turns out that doing this after rotation will re-align everything:
[self.navigationController.view layoutSubviews];
Kinda seems like the framework would call that, but I guess not.
___
Cocoa-dev mailing list
Kinda seems like the framework would call that, but I guess not.
It should and this shouldn't be necessary. A bug report would be good here.
Yes, I'm going to file one. While this workaround straightens the
layout after rotation, it's a little janky because things snap into
place after the
Ah, that sounds vagely familiar now. Thanks for the pointer, Conrad.
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at
We have a network-dependent app that will suffer from lengthy delays if
connectivity is poor. We've found that if the user quits the app during a
long network activity, the app will often crash upon its next launch.
Why? It shouldn't be retaining any state between launches.
Thanks for any
Hi all.
I have a tableview that displays data from a collection of C++ objects. In
the background, I download an updated collection occasionally, then
reconcile it with the one being shown by the tableview.
I coded it so the list reconciliation occurs on the main thread, but is that
enough to
Thanks for that thorough explanation, Wim. In most of my operations I'm
just calling C++ objects, so I doubted that I need the pool.
So far I'm pleased with operations and queues. Pretty cool and not hard to
use. Not too portable though, I guess...
Gavin
Hi all.
I haven't really managed autorelease pools explicitly before, but the
NSOperation doc says to use one in your NSOperation derivatives. My
question is where to put it. The example shows the pool being created and
released in the main() function, but I don't really allocate anything
At least for the duration of the app.
I'm presenting a UI that's as close as I can come to the built-in
camera app's: A controller brings up UIImagePickerController in
camera mode, with an overlay at the bottom that has a library
button on it. If the user presses the Library button, the overlay
1 - 100 of 126 matches
Mail list logo