Mac Cocoa |
Author |
Message |
XNote Kapetan
Joined: 16 Jun 2006 Posts: 532
|
Posted: Fri Sep 12, 2008 2:43 pm Post subject: Memory management |
|
|
Technical Q&A QA1367 - Finding EXC_BAD_ACCESS bugs in a Cocoa project
"This kind of problem is usually the result of over-releasing an object. It can
be very confusing, since the failure tends to occur well after the mistake is
made. The crash can also occur while the program is deep in framework code,
often with none of your own code visible in the stack." |
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3136 Location: Europe
|
Posted: Sat Sep 13, 2008 12:20 am Post subject: |
|
|
adc - Object Ownership and Disposal
"This document discusses the policy for ownership of Objective-C objects and
how and when to dispose of objects.
To fully understand how the object ownership policy is implemented in Cocoa,
you must also read Autorelease Pools." |
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Fri Sep 19, 2008 11:34 pm Post subject: |
|
|
SO - Understanding reference counting with Cocoa / Objective C
"I'm just beginning to have a look at Objective C and Cocoa with a view to
playing with he iPhone SDK. I'm reasonably comfortable with C's malloc and
free concept, but Cocoa's references counting scheme has me rather confused.
I'm told it's very elegant once you understand it, but I'm just not over the
hump yet." |
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Mon Oct 06, 2008 1:01 am Post subject: |
|
|
SO - Avoiding, finding and removing memory leaks in Cocoa
"Memory (and resource) leaks happen. How do you make sure they don't?
What tips & techniques would you suggest to help avoid creating memory
leaks in first place?" |
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3136 Location: Europe
|
Posted: Sat Oct 11, 2008 7:50 pm Post subject: |
|
|
SO - What is the cost of using autorelease on obj-c objects?
"Most of Apples documentation seems to avoid using autoreleased objects
especially when creating gui views, but I want to know what the cost of using
autoreleased objects is?" |
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3136 Location: Europe
|
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Mon Jan 26, 2009 1:05 am Post subject: |
|
|
iphonedevsdk.com - Is 8mb too much memory? (didReceiveMemoryWarning)
"You'd be very surprised at how different the environment is from one
device to the next. The iPhone will have 5-10MB less RAM from the get-go
with the extra phone services. Someone who browses heavily can have
another 10-20MB unavailable due to MobileSafari running at all times in
the background." |
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Thu Jan 29, 2009 1:22 am Post subject: |
|
|
iphonedevbook.com - Autorelease question for UITableViewCell
"If we release it ourselves, then the retain count gets set to 0 and the object
might be deallocated before the caller uses it. And if we do nothing, then we
have a memory leak." |
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3136 Location: Europe
|
Posted: Wed Jun 10, 2009 6:12 pm Post subject: |
|
|
MF - Is OS 3.0 GM memory hungry?
"I've been having some weird errors today, since upgrading to 3.0 GM. I
seem to be running out of memory. Nothings changed in my app, I'm in
the final stages of testing." |
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Sun May 09, 2010 11:45 pm Post subject: |
|
|
SO - Available memory for iPhone OS app
"I'm looking for a device-independent way (iPod touch, iPhone, iPad) to
know how much memory the app has left." |
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Thu Oct 28, 2010 11:36 pm Post subject: |
|
|
so - Get Device Memory Xcode
"The desktop uses the Mach call host_statistics64() to get that information.
You can see it in use in the source code for the vm_stat command." |
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3136 Location: Europe
|
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Sun Oct 23, 2011 3:04 am Post subject: |
|
|
MF - What is this new fangled ARC???
"You want to read the Transitioning to ARC Release Notes.
The Automatic Reference Counting section of the Xcode New Features
User Guide tell you about the new Xcode command for converting a pro-
ject to ARC.
You might want to read the Storyboarding section of that same guide.
Storyboarding is another new feature of XCode 4.2 which could make
your job easier.
...
You can turn ARC off per file or per project very easily by setting the
following -fno-objc-arc." |
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Tue May 22, 2012 1:34 am Post subject: |
|
|
LW - Understanding Automatic Reference Counting in Objective-C
"Despite its awesomeness, ARC does not let you ignore memory management
altogether.
Click on the Target
Select the Build Phases tab
Expand the Compile Sources section
Select one or more files you want to exclude from ARC
Press the return key
Type -fno-objc-arc" |
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Tue Jul 17, 2012 12:21 am Post subject: |
|
|
so - performSelector may cause a leak because its selector is unknown
"In the LLVM 3.0 compiler in Xcode 4.2 you can suppress the warning as
follows:"
Code: | #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[self.ticketTarget performSelector: self.ticketAction withObject: self];
#pragma clang diagnostic pop |
|
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3136 Location: Europe
|
Posted: Mon Dec 31, 2018 5:30 pm Post subject: |
|
|
a - Transitioning to ARC Release Notes
"Automatic Reference Counting (ARC) is a compiler feature that provides
automatic memory management of Objective-C objects. Rather than having
to think about retain and release operations, ARC allows you to concentrate
on the interesting code, the object graphs, and the relationships between
objects in your application." |
|
Back to top |
|
|
delovski
Joined: 14 Jun 2006 Posts: 3524 Location: Zagreb
|
Posted: Sat Jan 12, 2019 9:31 pm Post subject: |
|
|
so - performSelector may cause a leak because its selector is unknown
In the LLVM 3.0 compiler in Xcode 4.2 you can suppress the warning as
follows:
Code: | #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[self.ticketTarget performSelector: self.ticketAction withObject: self];
#pragma clang diagnostic pop
|
If you're getting the error in several places, and want to use the C macro
system to hide the pragmas, you can define a macro to make it easier to
suppress the warning:
Code: | #define SuppressPerformSelectorLeakWarning(Stuff) \
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
Stuff; \
_Pragma("clang diagnostic pop") \
} while (0) |
You can use the macro like this:
Code: | SuppressPerformSelectorLeakWarning(
[_target performSelector:_action withObject:self]
); |
If you need the result of the performed message, you can do this:
Code: | id result;
SuppressPerformSelectorLeakWarning(
result = [_target performSelector:_action withObject:self]
); |
|
|
Back to top |
|
|
Ike Kapetan
Joined: 17 Jun 2006 Posts: 3136 Location: Europe
|
Posted: Wed May 26, 2021 3:28 pm Post subject: |
|
|
SystemGenes - Stack Size : behind the code
"The stack word is very popular when it comes to C programming. It often
intrigues us that how much is the stack size of a process and how to know it." |
|
Back to top |
|
|
|