I'm trying to remove a UITabBarController from a window in my app by calling removeFromSuperview on the controller's view after adding it to the window previously. However when i do so and after it deallocates all the view controllers that are on the bar successfully, i get an EXC_BAD_ACCESS signal after an autorelease pool is drained. ...
I'm a total C newbie, I come from C#. I've been learning about memory management and the malloc() function. I've also came across this code:
char *a_persons_name = malloc(sizeof(char) + 2);
What I don't understand is how much space this is allocating for a_persons_name. Is it allocating 2 characters (eg. AB) or something else?
I als...
Using the following code:
char *name = malloc(sizeof(char) + 256);
printf("What is your name? ");
scanf("%s", name);
printf("Hello %s. Nice to meet you.\n", name);
A user can enter their name but when they enter a name with a space like Lucas Aardvark, scanf() just cuts off everything after Lucas. How do I make scanf() allow spaces...
When should one prefer object pool over dynamically allocated objects?
I need to create and destroy thousands of objects per second. Is it by itself enough to decide in favor of object pool?
Thanks.
...
We experience several minutes lags in our server. Probably they are triggered by "stop the world" garbage collections. But we use concurrent mark and sweep GC (-XX:+UseConcMarkSweepG) so, I think, these pauses are triggered by memory fragmentation of old generation.
How can memory fragmentation of old generation be analyzed? Are there ...
-(id)viewWillDisappear:(BOOL)animated
{
report_memory_str(@"BEFORE RELEASE viewWillDisappear");
self.view = nil;
report_memory_str(@"AFTER RELEASE viewWillDisappear");
}
When my view Disappear, i try to release current view before push to another controller,
i don't get more free memory, why ? How to get more free memory ?
2009-08-10...
I grabbed the crash log from the iPhone:
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000c
Crashed Thread: 0
Thread 0 Crashed:
0 libobjc.A.dylib 0x30011940 objc_msgSend + 20
1 CoreFoundation 0x30235f1e CFRelease + 98
2 UIKit ...
When I make an NSArray using +[NSArray arrayWithObjects:], does it copy those objects? If I release the objects after adding them to the array, will I run into problems?
...
I would like to understand what is going on in the GCC runtime in the following situation.
I have a C++ program that allocates many blocks of memory and then deletes them. What's puzzling is that the memory is not being returned to the OS by the GCC runtime. Instead, it is still being kept by my program, I assume in case I want to alloc...
Looking at some example code and come across some zero-size array allocation. I created the following code snippet to clarify my question
This is valid code:
class T
{
};
int main(void)
{
T * ptr = new T[0];
return 0;
}
What is its use? Is ptr valid? Is this construct portable?
...
I assign an object to an NSValue like this:
[NSValue valueWithNonretainedObject:myObject];
What happens if that object gets deallocated from memory, and then I try to pull it out from that NSValue? Would the reference be nil? How could I check if the object is still there? Or would the app just crash when something like this happens?
...
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier] autorelease];
...
return cell;
Wouldn't this code autorelease the cell before anything can be done with it...
I'm parsing an XML string and have a memory leak. I know this code is leaking, but not sure what the fix is:
http://pastie.org/580694
Code like this appears to be fundamentally flawed:
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)value{
if ([currentElement isEqualToString:@"problem_id"]){
currentProblem.p...
I'm developing an iPhone application that makes heavy use of Core Data, primarily for its database-like features (such as the ability to set a sort order or predicate on fetch requests). I'm presenting all the data I fetch in various UITableViewControllers.
What I'd like to know is a rough idea of how many objects I can fetch before it ...
When an instance method returns a value that was initialized with a convenience constructor, do I need to retain that object and then autorelease in the return so that when the convenience constructor's autorelease occurs, it doesn't remove the object.
Will this release description before the calling code and take ownership with a retai...
Hi! I realize the code sample below is something you should never do. My question is just one of interest. If you allocate a block of memory, and then move the pointer (a no-no), when you deallocate the memory, what is the size of the block that is deallocated, and where is it in memory? Here's the contrived code snippet:
#include <std...
I have a mobile application that is suffering from slow-down over time. My hunch, (In part fed by this article,) is that this is due to fragmentation of memory slowing the app down, but I'm not sure. Here's a pretty graph of the app's memory use over time:
The 4 peaks on the graph are 4 executions of the exact same task on the app. I ...
For my application, I have one UIViewController and about 8 UIViews. The views are all properties of the view controller, linked via the Interface Builder (IBOutlet). So when the view controller loads, all of the views are also loaded, and I have built-in methods to switch back and forth between the different views.
Is it bad to have th...
Hi, I am wondering about the delete[] operator in C++. (I am using Visual Studio 2005).
I have an unmanaged DLL that is being called by a managed DLL. When I close this program after performing a few tasks while debugging, I am getting many (thousands?) of memory leaks, mostly 24 bytes - 44 bytes in size.. I suspect it might be due to a...
hiiii
I want to know how memory is managed in blackberry to execute different applications simultaneously and with the help of which internal file or program or anything plz help me
thanks in advance
...